mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
feat: client-side hooks for navigator scroll action
This commit is contained in:
@@ -561,12 +561,14 @@ define('navigator', ['forum/pagination', 'components', 'hooks', 'alerts'], funct
|
||||
navigator.scrollToElement(scrollTo, highlight, duration, topicIndex);
|
||||
};
|
||||
|
||||
navigator.scrollToElement = function (scrollTo, highlight, duration, newIndex = null) {
|
||||
navigator.scrollToElement = async (scrollTo, highlight, duration, newIndex = null) => {
|
||||
if (!scrollTo.length) {
|
||||
navigator.scrollActive = false;
|
||||
return;
|
||||
}
|
||||
|
||||
await hooks.fire('filter:navigator.scroll', { scrollTo, highlight, duration, newIndex });
|
||||
|
||||
const postHeight = scrollTo.outerHeight(true);
|
||||
const navbarHeight = components.get('navbar').outerHeight(true);
|
||||
const topicHeaderHeight = $('.topic-header').outerHeight(true) || 0;
|
||||
@@ -584,6 +586,8 @@ define('navigator', ['forum/pagination', 'components', 'hooks', 'alerts'], funct
|
||||
// Re-enable onScroll behaviour
|
||||
setTimeout(() => { // fixes race condition from jQuery — onAnimateComplete called too quickly
|
||||
$(window).on('scroll', navigator.delayedUpdate);
|
||||
|
||||
hooks.fire('action:navigator.scrolled', { scrollTo, highlight, duration, newIndex });
|
||||
}, 50);
|
||||
}
|
||||
function onAnimateComplete() {
|
||||
|
||||
Reference in New Issue
Block a user