fix intersection observer bug in firefox
This commit is contained in:
parent
8725225b68
commit
e467f74631
|
@ -113,10 +113,7 @@
|
|||
oncreate() {
|
||||
let realm = this.get('realm')
|
||||
if (realm === 'home') {
|
||||
this.__stickyObserver = new IntersectionObserver(entries => {
|
||||
this.set({sticky: !entries[0].isIntersecting})
|
||||
})
|
||||
this.__stickyObserver.observe(this.refs.sentinel)
|
||||
this.setupStickyObserver()
|
||||
} else if (realm !== 'dialog') {
|
||||
// if this is a reply, populate the handle immediately
|
||||
insertHandleForReply(realm)
|
||||
|
@ -130,9 +127,7 @@
|
|||
}, {init: false})
|
||||
},
|
||||
ondestroy() {
|
||||
if (this.__stickyObserver) {
|
||||
this.__stickyObserver.disconnect()
|
||||
}
|
||||
this.teardownStickyObserver()
|
||||
},
|
||||
components: {
|
||||
ComposeAuthor,
|
||||
|
@ -182,7 +177,8 @@
|
|||
overLimit: (length) => length > CHAR_LIMIT,
|
||||
contentWarningShown: (composeData) => composeData.contentWarningShown,
|
||||
contentWarning: (composeData) => composeData.contentWarning || '',
|
||||
postedStatusForRealm: ($postedStatusForRealm) => $postedStatusForRealm
|
||||
postedStatusForRealm: ($postedStatusForRealm) => $postedStatusForRealm,
|
||||
timelineInitialized: ($timelineInitialized) => $timelineInitialized
|
||||
},
|
||||
transitions: {
|
||||
slide
|
||||
|
@ -214,6 +210,30 @@
|
|||
postStatus(realm, text, inReplyTo, mediaIds,
|
||||
sensitive, contentWarning, postPrivacyKey)
|
||||
}
|
||||
},
|
||||
setupStickyObserver() {
|
||||
this.__stickyObserver = new IntersectionObserver(entries => {
|
||||
this.set({sticky: !entries[0].isIntersecting})
|
||||
})
|
||||
this.__stickyObserver.observe(this.refs.sentinel)
|
||||
|
||||
// also create a one-shot observer for the $timelineInitialized event,
|
||||
// due to a bug in Firefox where when the scrollTop is set
|
||||
// manually, the other observer doesn't necessarily fire
|
||||
this.observe('timelineInitialized', timelineInitialized => {
|
||||
if (timelineInitialized) {
|
||||
let observer = new IntersectionObserver(entries => {
|
||||
this.set({sticky: !entries[0].isIntersecting})
|
||||
observer.disconnect()
|
||||
})
|
||||
observer.observe(this.refs.sentinel)
|
||||
}
|
||||
}, {init: false})
|
||||
},
|
||||
teardownStickyObserver() {
|
||||
if (this.__stickyObserver) {
|
||||
this.__stickyObserver.disconnect()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue