MCPcopy Create free account
hub / github.com/dailydotdev/apps / glideTo

Function glideTo

packages/shared/src/components/shell/ReadingDrawer.tsx:621–651  ·  view source on GitHub ↗
(target: number, onEnd?: () => void)

Source from the content-addressed store, hash-verified

619 settleAt(target);
620 };
621 const glideTo = (target: number, onEnd?: () => void) => {
622 const from = virtualY ?? restingY();
623 refreshMoving();
624 dropGlide();
625 if (Math.abs(target - from) < 1) {
626 settleAt(target);
627 onEnd?.();
628 return;
629 }
630 glideTarget = target;
631 afterGlide = onEnd;
632 styleMoving({
633 transition: `transform ${motion.snap}ms var(--shell-ease-travel)`,
634 'will-change': 'transform',
635 });
636 present(target);
637 const started = performance.now();
638 const step = (now: number) => {
639 const t = Math.min(1, (now - started) / motion.snap);
640 virtualY = from + (target - from) * ease(t);
641 update();
642 if (t < 1) {
643 glideFrame = requestAnimationFrame(step);
644 return;
645 }
646 const done = afterGlide;
647 landGlide();
648 done?.();
649 };
650 glideFrame = requestAnimationFrame(step);
651 };
652 glide.current = glideTo;
653 sink.current = () => glideTo(current.card);
654

Callers 4

ReadingDrawerFunction · 0.70
onTouchEndFunction · 0.70
onArticleScrollFunction · 0.70
onClickFunction · 0.70

Calls 7

restingYFunction · 0.85
refreshMovingFunction · 0.85
dropGlideFunction · 0.85
settleAtFunction · 0.85
styleMovingFunction · 0.85
presentFunction · 0.85
nowMethod · 0.80

Tested by

no test coverage detected