MCPcopy
hub / github.com/dolphin-wood/smooth-scrollbar / _shouldPropagateMomentum

Method _shouldPropagateMomentum

src/scrollbar.ts:435–462  ·  view source on GitHub ↗
(deltaX = 0, deltaY = 0)

Source from the content-addressed store, hash-verified

433 // 1. continuous scrolling is enabled (automatically disabled when overscroll is enabled)
434 // 2. scrollbar reaches one side and is not about to scroll on the other direction
435 private _shouldPropagateMomentum(deltaX = 0, deltaY = 0): boolean {
436 const {
437 options,
438 offset,
439 limit,
440 } = this;
441
442 if (!options.continuousScrolling) return false;
443
444 // force an update when scrollbar is "unscrollable", see #106
445 if (limit.x === 0 && limit.y === 0) {
446 this._updateDebounced();
447 }
448
449 const destX = clamp(deltaX + offset.x, 0, limit.x);
450 const destY = clamp(deltaY + offset.y, 0, limit.y);
451 let res = true;
452
453 // offsets are not about to change
454 // `&=` operator is not allowed for boolean types
455 res = res && (destX === offset.x);
456 res = res && (destY === offset.y);
457
458 // current offsets are on the edge
459 res = res && (offset.x === limit.x || offset.x === 0 || offset.y === limit.y || offset.y === 0);
460
461 return res;
462 }
463
464 private _render() {
465 const {

Callers 1

Calls 2

_updateDebouncedMethod · 0.95
clampFunction · 0.90

Tested by

no test coverage detected