From 578cdadb623702e64b50d9d69b896b1d4623eb90 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Fri, 5 Jan 2018 09:37:27 +1000 Subject: [PATCH] Do not apply body offset if the body element doesn't have any position. --- src/helpers.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/helpers.js b/src/helpers.js index 6f43321..7b1f29b 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -3,6 +3,12 @@ export function removeHtmlTags (text) { } export function getBodyOffset () { + // Do not return offset if the body element doesn't have any position. + if (document.body.style.position === 'static' || + document.body.style.position === '') { + return { top: 0, left: 0 }; + } + const rectBody = document.body.getBoundingClientRect(); const rectDocument = document.documentElement.getBoundingClientRect();