mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Clamp divisor
Although the max width is min-inline-size * max-column-count, sometimes the actual width apparently doesn't match that exactly.
This commit is contained in:
+2
-1
@@ -533,6 +533,7 @@ export class Paginator extends HTMLElement {
|
|||||||
|
|
||||||
const style = getComputedStyle(this)
|
const style = getComputedStyle(this)
|
||||||
const maxInlineSize = parseFloat(style.getPropertyValue('--_max-inline-size'))
|
const maxInlineSize = parseFloat(style.getPropertyValue('--_max-inline-size'))
|
||||||
|
const maxColumnCount = parseInt(style.getPropertyValue('--_max-column-count'))
|
||||||
const margin = parseFloat(style.getPropertyValue('--_margin'))
|
const margin = parseFloat(style.getPropertyValue('--_margin'))
|
||||||
this.#margin = margin
|
this.#margin = margin
|
||||||
|
|
||||||
@@ -571,7 +572,7 @@ export class Paginator extends HTMLElement {
|
|||||||
return { flow, margin, gap, columnWidth }
|
return { flow, margin, gap, columnWidth }
|
||||||
}
|
}
|
||||||
|
|
||||||
const divisor = Math.ceil(size / maxInlineSize)
|
const divisor = Math.min(maxColumnCount, Math.ceil(size / maxInlineSize))
|
||||||
const columnWidth = (size / divisor) - gap
|
const columnWidth = (size / divisor) - gap
|
||||||
this.setAttribute('dir', rtl ? 'rtl' : 'ltr')
|
this.setAttribute('dir', rtl ? 'rtl' : 'ltr')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user