scrollElementIntoView: skip if orphaned
This commit is contained in:
parent
97178eca46
commit
8cad7d61eb
|
@ -96,6 +96,7 @@ function onDOMready() {
|
||||||
|
|
||||||
function scrollElementIntoView(element, {invalidMarginRatio = 0} = {}) {
|
function scrollElementIntoView(element, {invalidMarginRatio = 0} = {}) {
|
||||||
// align to the top/bottom of the visible area if wasn't visible
|
// align to the top/bottom of the visible area if wasn't visible
|
||||||
|
if (!element.parentNode) return;
|
||||||
const {top, height} = element.getBoundingClientRect();
|
const {top, height} = element.getBoundingClientRect();
|
||||||
const {top: parentTop, bottom: parentBottom} = element.parentNode.getBoundingClientRect();
|
const {top: parentTop, bottom: parentBottom} = element.parentNode.getBoundingClientRect();
|
||||||
const windowHeight = window.innerHeight;
|
const windowHeight = window.innerHeight;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user