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

Function animateTabReorder

src/handlers/editorFileTab.js:345–391  ·  view source on GitHub ↗

* Animates the visual change after the DOM order is updated using FLIP. * Uses WAAPI directly for reliable mid-animation compositing and to * properly respect the app's no-animation setting. * @param {HTMLElement} $parent * @param {Map } previousRects

($parent, previousRects)

Source from the content-addressed store, hash-verified

343 * @param {Map<HTMLElement, DOMRect>} previousRects
344 */
345function animateTabReorder($parent, previousRects) {
346 for (const $child of $parent.children) {
347 if ($child === $tab) continue;
348
349 const oldAnim = reorderAnimations.get($child);
350 if (oldAnim) {
351 oldAnim.cancel();
352 reorderAnimations.delete($child);
353 }
354
355 const previousRect = previousRects.get($child);
356 if (!previousRect) continue;
357
358 const currentRect = $child.getBoundingClientRect();
359 const deltaX = previousRect.left - currentRect.left;
360 const deltaY = previousRect.top - currentRect.top;
361
362 if (Math.abs(deltaX) < 0.5 && Math.abs(deltaY) < 0.5) continue;
363
364 const anim = $child.animate(
365 [
366 { transform: `translate3d(${deltaX}px, ${deltaY}px, 0)` },
367 { transform: "translate3d(0, 0, 0)" },
368 ],
369 {
370 duration: document.body.classList.contains("no-animation")
371 ? 0
372 : REORDER_DURATION,
373 easing: SPRING_EASING,
374 fill: "none",
375 composite: "replace",
376 },
377 );
378 reorderAnimations.set($child, anim);
379
380 anim.onfinish = () => {
381 if (reorderAnimations.get($child) === anim) {
382 reorderAnimations.delete($child);
383 }
384 };
385 anim.oncancel = () => {
386 if (reorderAnimations.get($child) === anim) {
387 reorderAnimations.delete($child);
388 }
389 };
390 }
391}
392
393/**
394 * Scrolls the container using animation frame

Callers 1

reorderTabFunction · 0.85

Calls 5

cancelMethod · 0.80
animateMethod · 0.80
setMethod · 0.80
deleteMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected