MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / getScroll

Function getScroll

src/handlers/editorFileTab.js:472–497  ·  view source on GitHub ↗

* Checks if the tab is going to scroll and returns the scroll value

()

Source from the content-addressed store, hash-verified

470 * Checks if the tab is going to scroll and returns the scroll value
471 */
472function getScroll() {
473 const tabRight = tabLeft + tabWidth;
474 const scrollX = $parent.scrollLeft;
475
476 /**@type {number} scroll value */
477 let scroll = 0;
478
479 // tab right should be greater than parent right
480 const rightDiff = tabRight - parentRight;
481 // tab left should be less than parent left
482 const leftDiff = parentLeft - tabLeft;
483
484 const scrollSpeed = (diff) => {
485 const t = Math.min(diff / tabWidth, 1);
486 const eased = t * t;
487 return MIN_SCROLL_SPEED + eased * (MAX_SCROLL_SPEED - MIN_SCROLL_SPEED);
488 };
489
490 if (leftDiff > 0 && scrollX > MIN_SCROLL) {
491 scroll = -scrollSpeed(leftDiff);
492 } else if (rightDiff > 0 && scrollX < MAX_SCROLL) {
493 scroll = scrollSpeed(rightDiff);
494 }
495
496 return scroll;
497}

Callers 2

onDragFunction · 0.85
animateFunction · 0.85

Calls 1

scrollSpeedFunction · 0.85

Tested by

no test coverage detected