fix: race condition where navigator.update was called when it should not be

This commit is contained in:
Julian Lam
2022-09-19 11:09:22 -04:00
parent 9f9a835fcb
commit fa643eb808

View File

@@ -581,9 +581,9 @@ define('navigator', ['forum/pagination', 'components', 'hooks', 'alerts'], funct
function animateScroll() {
function reenableScroll() {
// Re-enable onScroll behaviour
$(window).on('scroll', navigator.delayedUpdate);
const scrollToRect = scrollTo.get(0).getBoundingClientRect();
navigator.update(scrollToRect.top);
setTimeout(() => { // fixes race condition from jQuery — onAnimateComplete called too quickly
$(window).on('scroll', navigator.delayedUpdate);
}, 50);
}
function onAnimateComplete() {
if (done) {