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

Function animate

src/highlight.ts:108–148  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106 setState("activeElement", toElement);
107
108 const animate = () => {
109 const transitionCallback = getState("__transitionCallback");
110
111 // This makes sure that the repeated calls to transferHighlight
112 // don't interfere with each other. Only the last call will be
113 // executed.
114 if (transitionCallback !== animate) {
115 return;
116 }
117
118 const elapsed = Date.now() - start;
119 const timeRemaining = duration - elapsed;
120 const isHalfwayThrough = timeRemaining <= duration / 2;
121
122 if (toStep.popover && isHalfwayThrough && !isPopoverRendered && hasDelayedPopover) {
123 renderPopover(toElement, toStep);
124 isPopoverRendered = true;
125 }
126
127 if (getConfig("animate") && elapsed < duration) {
128 transitionStage(elapsed, duration, fromElement, toElement);
129 } else {
130 trackActiveElement(toElement);
131
132 if (highlightedHook) {
133 highlightedHook(isToDummyElement ? undefined : toElement, toStep, {
134 config: getConfig(),
135 state: getState(),
136 driver: getCurrentDriver(),
137 });
138 }
139
140 setState("__transitionCallback", undefined);
141 setState("__previousStep", fromStep);
142 setState("__previousElement", fromElement);
143 setState("__activeStep", toStep);
144 setState("__activeElement", toElement);
145 }
146
147 window.requestAnimationFrame(animate);
148 };
149
150 setState("__transitionCallback", animate);
151

Callers

nothing calls this directly

Calls 7

getStateFunction · 0.90
renderPopoverFunction · 0.90
getConfigFunction · 0.90
transitionStageFunction · 0.90
trackActiveElementFunction · 0.90
getCurrentDriverFunction · 0.90
setStateFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…