diff --git a/src/domobserver.ts b/src/domobserver.ts index 55d87c6a..c2550fe9 100644 --- a/src/domobserver.ts +++ b/src/domobserver.ts @@ -99,7 +99,7 @@ export class DOMObserver { if (typeof IntersectionObserver == "function") { this.intersection = new IntersectionObserver(entries => { if (this.parentCheck < 0) this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1000) - if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0 != this.intersecting) { + if (entries.length > 0 && (entries[entries.length - 1].intersectionRatio > 0) != this.intersecting) { this.intersecting = !this.intersecting if (this.intersecting != this.view.inView) this.onScrollChanged(document.createEvent("Event")) diff --git a/src/viewstate.ts b/src/viewstate.ts index d4ffcb7c..2d6e1a3b 100644 --- a/src/viewstate.ts +++ b/src/viewstate.ts @@ -239,7 +239,11 @@ export class ViewState { let pixelViewport = this.printing ? {top: -1e8, bottom: 1e8, left: -1e8, right: 1e8} : visiblePixelRange(dom, this.paddingTop) let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom this.pixelViewport = pixelViewport - this.inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left + let inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left + if (inView != this.inView) { + this.inView = inView + if (inView) measureContent = true + } if (!this.inView) return 0 if (measureContent) {