MCPcopy Index your code
hub / github.com/gridstack/gridstack.js / updateScrollPosition

Method updateScrollPosition

src/dd-draggable.ts:432–440  ·  view source on GitHub ↗

@internal starts or continues auto-scroll when the dragged helper is clipped by the scroll container. * Takes the grid's own element to find the scroll container so external/sidebar drags work too (#2074).

(gridEl: HTMLElement)

Source from the content-addressed store, hash-verified

430 /** @internal starts or continues auto-scroll when the dragged helper is clipped by the scroll container.
431 * Takes the grid's own element to find the scroll container so external/sidebar drags work too (#2074). */
432 public updateScrollPosition(gridEl: HTMLElement): void {
433 this._autoScrollContainer = Utils.getScrollElement(gridEl); // always use latest active grid
434 const clipping = this._getClipping(this.helper, this._autoScrollContainer);
435 if (clipping === 0) {
436 this._stopScrolling();
437 } else if (!this._autoScrollAnimId) {
438 this._autoScrollAnimId = requestAnimationFrame(this._autoScrollTick);
439 }
440 }
441
442 /** @internal compute how many pixels the element is clipped: negative = above, positive = below, 0 = fully inside OR outside (stop scrolling) */
443 protected _getClipping(el: HTMLElement, scrollEl: HTMLElement): number {

Callers 2

_dragOrResizeMethod · 0.80
utils-spec.tsFile · 0.80

Calls 3

_getClippingMethod · 0.95
_stopScrollingMethod · 0.95
getScrollElementMethod · 0.80

Tested by

no test coverage detected