From 394a1ba4b04f68dfce9c0727fe1da9a5a6beb3c4 Mon Sep 17 00:00:00 2001 From: borunovm Date: Thu, 26 Dec 2019 11:13:59 +0300 Subject: [PATCH] improved condition checking for scroll offset function --- modules/mixins/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/mixins/utils.js b/modules/mixins/utils.js index aab8a14b..315be466 100644 --- a/modules/mixins/utils.js +++ b/modules/mixins/utils.js @@ -24,8 +24,8 @@ const filterElementInContainer = (container) => (element) => container.contains const calculatingOffsetParent = (c, t) => t.offsetParent.isEqualNode(c) ? t.offsetTop : t.offsetTop + calculatingOffsetParent(c, t.offsetParent); -const scrollOffset = (c, t) => c === document ? - t.getBoundingClientRect().top + (window.scrollY || window.pageYOffset) : getComputedStyle(c).position !== 'static' ? calculatingOffsetParent(c, t) : calculatingOffsetParent(c.offsetParent, t.offsetParent) - c.offsetTop; +const scrollOffset = (c, t) => c === document || c === document.body || c === document.documentElement ? + t.getBoundingClientRect().top + (window.scrollY || window.pageYOffset) : getComputedStyle(c).position === 'static' ? calculatingOffsetParent(c.offsetParent, t.offsetParent) - c.offsetTop : calculatingOffsetParent(c, t); export default { pushHash,