1
0
Fork 0

change to bin-pack-with-constraints

This commit is contained in:
Enoch Riese 2023-02-27 18:58:47 -06:00
parent dc998d4e98
commit 6ba2e4e885
4 changed files with 9 additions and 8 deletions

View file

@ -1,5 +1,5 @@
import { Attributes } from './attributes.mjs'
import pack from 'bin-pack'
import pack from 'bin-pack-with-constraints'
import { __addNonEnumProp, __macroName } from './utils.mjs'
import { Part } from './part.mjs'
import { Stack } from './stack.mjs'
@ -72,6 +72,7 @@ Pattern.prototype.addPart = function (part, resolveImmediately = true) {
this.__configResolver.isPartValid(part) &&
!this.designConfig.parts.find((p) => p.name == part.name)
) {
this.store.log.debug(`Adding Part \`${part.name}\` at runtime`)
this.designConfig.parts.push(part)
if (resolveImmediately) {
if (this.__configResolver.addPart(part) && typeof this.draftQueue !== 'undefined')
@ -922,7 +923,7 @@ Pattern.prototype.__pack = function () {
}
}
if (this.settings[0].layout === true) {
let size = pack(bins, { inPlace: true })
let size = pack(bins, { inPlace: true, maxWidth: this.settings[0].maxWidth })
for (let bin of bins) {
this.autoLayout.stacks[bin.id] = { move: {} }
let stack = this.stacks[bin.id]