MCPcopy
hub / github.com/handsontable/handsontable / scrollViewportHorizontally

Function scrollViewportHorizontally

handsontable/test/helpers/common.js:710–729  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

708 * @param {number} x The scroll position.
709 */
710export async function scrollViewportHorizontally(x) {
711 const isWindow = hot().view._wt.wtOverlays.scrollableElement === hot().rootWindow;
712 const scrollableElement = isWindow ? window : getMaster().find('.wtHolder')[0];
713
714 return new Promise((resolve) => {
715 const scrollHandler = () => {
716 scrollableElement.removeEventListener('scroll', scrollHandler);
717 resolve();
718 };
719
720 scrollableElement.addEventListener('scroll', scrollHandler);
721 x = hot().isRtl() ? -x : x;
722
723 if (isWindow) {
724 scrollableElement.scrollTo(x, scrollableElement.scrollY);
725 } else {
726 scrollableElement.scrollLeft = x;
727 }
728 });
729}
730
731/**
732 * Moves the browser's viewport to the specified x and y scroll position.

Callers

nothing calls this directly

Calls 5

getMasterFunction · 0.85
addEventListenerMethod · 0.80
hotFunction · 0.70
isRtlMethod · 0.65
scrollToMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…