Skip to content

Commit

Permalink
chore(grid): improve strictAutoFit
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Dec 15, 2021
1 parent ad82905 commit d485a49
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions packages/grid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,24 +311,42 @@ export class Grid<Container extends HTMLElement> {

const baseColumns = this.childSize

const maxWidthColumns = Math.min(
const strictMaxWidthColumns = Math.round(
this.width / (this.maxWidth + this.columnGap)
)

const looseMaxWidthColumns = Math.min(
originTotalColumns,
Math.round(this.width / (this.maxWidth + this.columnGap))
strictMaxWidthColumns
)

const maxWidthColumns = this.options.strictAutoFit
? strictMaxWidthColumns
: looseMaxWidthColumns

const strictMinWidthColumns = Math.round(
this.width / (this.minWidth + this.columnGap)
)

const minWidthColumns = Math.min(
const looseMinWidthColumns = Math.min(
originTotalColumns,
Math.round(this.width / (this.minWidth + this.columnGap))
strictMinWidthColumns
)

const minWidthColumns = this.options.strictAutoFit
? strictMinWidthColumns
: looseMinWidthColumns

const minCalculatedColumns = Math.min(
baseColumns,
originTotalColumns,
maxWidthColumns,
minWidthColumns
)

const maxCalculatedColumns = Math.max(
baseColumns,
originTotalColumns,
maxWidthColumns,
minWidthColumns
)
Expand Down

0 comments on commit d485a49

Please sign in to comment.