mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Don't check document's existence when expanding
`expand()` is only called after `render()`, which assumes that it exists
This commit is contained in:
+4
-5
@@ -308,11 +308,12 @@ class View {
|
||||
}
|
||||
}
|
||||
expand() {
|
||||
const { documentElement } = this.document
|
||||
if (this.#column) {
|
||||
const side = this.#vertical ? 'height' : 'width'
|
||||
const otherSide = this.#vertical ? 'width' : 'height'
|
||||
const contentRect = this.#contentRange.getBoundingClientRect()
|
||||
const rootRect = this.document.documentElement.getBoundingClientRect()
|
||||
const rootRect = documentElement.getBoundingClientRect()
|
||||
// offset caused by column break at the start of the page
|
||||
// which seem to be supported only by WebKit and only for horizontal writing
|
||||
const contentStart = this.#vertical ? 0
|
||||
@@ -325,8 +326,7 @@ class View {
|
||||
this.#element.style[side] = `${expandedSize + this.#size * 2}px`
|
||||
this.#iframe.style[otherSide] = '100%'
|
||||
this.#element.style[otherSide] = '100%'
|
||||
if (this.document)
|
||||
this.document.documentElement.style[side] = `${this.#size}px`
|
||||
documentElement.style[side] = `${this.#size}px`
|
||||
if (this.#overlayer) {
|
||||
this.#overlayer.element.style.margin = '0'
|
||||
this.#overlayer.element.style.left = this.#vertical ? '0' : `${this.#size}px`
|
||||
@@ -337,8 +337,7 @@ class View {
|
||||
} else {
|
||||
const side = this.#vertical ? 'width' : 'height'
|
||||
const otherSide = this.#vertical ? 'height' : 'width'
|
||||
const doc = this.document
|
||||
const contentSize = doc?.documentElement?.getBoundingClientRect()?.[side]
|
||||
const contentSize = documentElement.getBoundingClientRect()[side]
|
||||
const expandedSize = contentSize
|
||||
const { margin } = this.#layout
|
||||
const padding = this.#vertical ? `0 ${margin}px` : `${margin}px 0`
|
||||
|
||||
Reference in New Issue
Block a user