Skip to content

feat(core): add Motion (motion.dev) runtime adapter#582

Closed
miguel-heygen wants to merge 1 commit intomainfrom
feat/motion-adapter
Closed

feat(core): add Motion (motion.dev) runtime adapter#582
miguel-heygen wants to merge 1 commit intomainfrom
feat/motion-adapter

Conversation

@miguel-heygen
Copy link
Copy Markdown
Collaborator

Summary

  • Adds a RuntimeDeterministicAdapter for Motion v12+ (motion.dev) — the framework-agnostic library from the creators of Framer Motion
  • Seeks via the .time setter (seconds) on animation instances registered via window.__hfMotion
  • Runs before the WAAPI adapter in the adapter chain so Motion owns its animations while the generic WAAPI adapter catches the rest

Usage in compositions

<script src="https://cdn.jsdelivr.net/npm/motion@12/dist/motion.min.js"></script>
<script>
  const { animate, stagger, spring } = Motion;
  const anim = animate('.box', { x: 250, rotate: 360 }, {
    duration: 2,
    ease: spring(),
  });
  window.__hfMotion = window.__hfMotion || [];
  window.__hfMotion.push(anim);
</script>

Files changed

  • packages/core/src/runtime/adapters/motion.ts — adapter implementation
  • packages/core/src/runtime/adapters/motion.test.ts — 11 unit tests
  • packages/core/src/runtime/init.ts — register adapter before WAAPI
  • packages/core/src/runtime/window.d.ts — add Motion and __hfMotion globals

Test plan

  • All 11 unit tests pass
  • All 84 adapter tests pass (full suite: gsap, css, waapi, lottie, three, animejs, motion)
  • Build passes
  • Pre-commit hooks pass (lint, format, typecheck, commitlint)

Add a RuntimeDeterministicAdapter for Motion v12+ (the framework-agnostic
library from the creators of Framer Motion).

The adapter:
- Seeks via the .time setter (seconds) on animation instances
- Accepts manual registration via window.__hfMotion
- Runs before the WAAPI adapter so Motion owns its animations and
  the generic WAAPI adapter catches the rest

Follows the same pattern as the anime.js, Lottie, Three.js, WAAPI,
and CSS adapters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant