MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / scrollClientRegionIntoContainerView

Function scrollClientRegionIntoContainerView

javascript/atoms/action.js:741–758  ·  view source on GitHub ↗
(container)

Source from the content-addressed store, hash-verified

739 bot.dom.getOverflowState(element, opt_region);
740
741 function scrollClientRegionIntoContainerView(container) {
742 // Based largely from goog.style.scrollIntoContainerView.
743 var containerRect = bot.dom.getClientRect(container);
744 var containerBorder = goog.style.getBorderBox(container);
745
746 // Relative position of the region to the container's content box.
747 var relX = region.left - containerRect.left - containerBorder.left;
748 var relY = region.top - containerRect.top - containerBorder.top;
749
750 // How much the region can move in the container. Use the container's
751 // clientWidth/Height, not containerRect, to account for the scrollbar.
752 var spaceX = container.clientWidth + region.left - region.right;
753 var spaceY = container.clientHeight + region.top - region.bottom;
754
755 // Scroll the element into view of the container.
756 container.scrollLeft += Math.min(relX, Math.max(relX - spaceX, 0));
757 container.scrollTop += Math.min(relY, Math.max(relY - spaceY, 0));
758 }
759};

Callers 1

action.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected