scrollElementIntoView: skip if orphaned

This commit is contained in:
tophf 2018-04-17 22:34:18 +03:00
parent 97178eca46
commit 8cad7d61eb

View File

@ -96,6 +96,7 @@ function onDOMready() {
function scrollElementIntoView(element, {invalidMarginRatio = 0} = {}) {
// align to the top/bottom of the visible area if wasn't visible
if (!element.parentNode) return;
const {top, height} = element.getBoundingClientRect();
const {top: parentTop, bottom: parentBottom} = element.parentNode.getBoundingClientRect();
const windowHeight = window.innerHeight;