diff options
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r-- | app/assets/javascripts/lib/utils/sticky.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/app/assets/javascripts/lib/utils/sticky.js b/app/assets/javascripts/lib/utils/sticky.js index f53acaa17b1..b5fde040a17 100644 --- a/app/assets/javascripts/lib/utils/sticky.js +++ b/app/assets/javascripts/lib/utils/sticky.js @@ -1,5 +1,5 @@ -export const isSticky = (el, stickyTop) => { - const top = el.getBoundingClientRect().top; +export const isSticky = (el, scrollY, stickyTop) => { + const top = el.offsetTop - scrollY; if (top === stickyTop) { el.classList.add('is-stuck'); @@ -15,7 +15,7 @@ export default (el) => { const stickyTop = parseInt(computedStyle.top, 10); - document.addEventListener('scroll', () => isSticky(el, stickyTop), { + document.addEventListener('scroll', () => isSticky(el, window.scrollY, stickyTop), { passive: true, }); }; |