Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 2x | import computeScrollIntoView from 'compute-scroll-into-view'; /** * Scroll node into view if necessary * @param {HTMLElement} node the element that should scroll into view * @param {HTMLElement} rootNode the root element of the component */ // eslint-disable-next-line export const scrollIntoView = (node, rootNode) => { if (node === null) { return; } const actions = computeScrollIntoView(node, { boundary: rootNode, block: 'nearest', scrollMode: 'if-needed' }); actions.forEach(({ el, top, left }) => { el.scrollTop = top; el.scrollLeft = left; }); }; |