Overlay path covering element to highlight when outside of the initial window
Author: cmazereauCreated Jul 11, 2022Updated Dec 10, 2024
Labelsbug
When an element to highlight is outside of the initial window (and needs to be scrolled to), the overlay covers this element.
It appears that the svg path of the overlay is calculated using _getVisibleHeight(), which returns 0 in that case.
This seems to be due to the fact that _getVisibleHeight() uses scrollParent.getBoundingClientRect(), without taking window.scrollY into account. The modification of _getVisibleHeight() as follow seems to resolve the issue :
if (scrollParent) {
const scrollRect = scrollParent.getBoundingClientRect();
const scrollTop = scrollRect.y || scrollRect.top;
const scrollBottom = scrollRect.bottom || scrollTop + scrollRect.height;
top = Math.max(top, window.scrollY + scrollTop);
bottom = Math.min(bottom, window.scrollY + scrollBottom);
}Source: shipshapecode/shepherd