MCPcopy
hub / github.com/nilbuild/driver.js / transitionStage

Function transitionStage

src/overlay.ts:16–36  ·  view source on GitHub ↗
(elapsed: number, duration: number, from: Element, to: Element)

Source from the content-addressed store, hash-verified

14// This method calculates the animated new position of the
15// stage (called for each frame by requestAnimationFrame)
16export function transitionStage(elapsed: number, duration: number, from: Element, to: Element) {
17 let activeStagePosition = getState("__activeStagePosition");
18
19 const fromDefinition = activeStagePosition ? activeStagePosition : from.getBoundingClientRect();
20 const toDefinition = to.getBoundingClientRect();
21
22 const x = easeInOutQuad(elapsed, fromDefinition.x, toDefinition.x - fromDefinition.x, duration);
23 const y = easeInOutQuad(elapsed, fromDefinition.y, toDefinition.y - fromDefinition.y, duration);
24 const width = easeInOutQuad(elapsed, fromDefinition.width, toDefinition.width - fromDefinition.width, duration);
25 const height = easeInOutQuad(elapsed, fromDefinition.height, toDefinition.height - fromDefinition.height, duration);
26
27 activeStagePosition = {
28 x,
29 y,
30 width,
31 height,
32 };
33
34 renderOverlay(activeStagePosition);
35 setState("__activeStagePosition", activeStagePosition);
36}
37
38export function trackActiveElement(element: Element) {
39 if (!element) {

Callers 1

animateFunction · 0.90

Calls 4

getStateFunction · 0.90
easeInOutQuadFunction · 0.90
setStateFunction · 0.90
renderOverlayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…