Prevent endless loop when zooming in/out and dismiss popup on scroll event
This commit is contained in:
parent
3d6c7fcd60
commit
29e83ccc0a
23
service.js
23
service.js
@ -274,10 +274,31 @@ class BesService {
|
||||
this.eventSink.endProofing(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporarily disables the mutation observer.
|
||||
*/
|
||||
disableMutationObserver() {
|
||||
if (this.mutationObserver) this.mutationObserver.disconnect()
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-enables the mutation observer.
|
||||
*/
|
||||
enableMutationObserver() {
|
||||
if (this.mutationObserver) {
|
||||
this.mutationObserver.observe(document.body, {
|
||||
attributes: true,
|
||||
childList: true,
|
||||
subtree: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to report scrolling
|
||||
*/
|
||||
onScroll() {
|
||||
this.dismissPopup()
|
||||
// Scroll panel is "position: absolute", we need to keep it aligned with the host element.
|
||||
this.scrollPanel.style.top = `${-this.hostElement.scrollTop}px`
|
||||
this.scrollPanel.style.left = `${-this.hostElement.scrollLeft}px`
|
||||
@ -409,6 +430,7 @@ class BesService {
|
||||
* Resizes correction and scroll panels to match host element size.
|
||||
*/
|
||||
setCorrectionPanelSize() {
|
||||
this.disableMutationObserver()
|
||||
const styles = window.getComputedStyle(this.hostElement)
|
||||
this.correctionPanel.style.marginLeft = styles.marginLeft
|
||||
this.correctionPanel.style.marginTop = styles.marginTop
|
||||
@ -445,6 +467,7 @@ class BesService {
|
||||
this.correctionPanel.style.width = styles.width
|
||||
this.correctionPanel.style.height = styles.height
|
||||
}
|
||||
this.enableMutationObserver()
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user