Migration Guide¶
This page focuses on the fastest way to switch engines. For shared behavior and feature tradeoffs, read Engine Overview.
All engines share the same builder API, so animation definitions usually stay the same. Most migration work is in integration points like init, update, subscriptions, view wiring, and WAAPI JavaScript setup.
How To Use This Page¶
Most migrations follow this flow:
- Change the engine import.
- Recompile.
- Follow compiler errors in order.
- Apply the target engine checklist below.
You are usually moving between:
- State tracked engines:
Transition,Keyframe,Sub,WAAPI - Timeline engines:
ScrollTimeline,ViewTimeline
Timeline engines are command based and do not use AnimState, update, or subscriptions.
Compiler First Workflow¶
Use this sequence for any migration:
- Change import and module alias.
- Update
initsignature and call shape. - Update trigger calls (
animateand optionalfireAndForget). - Update
updatehandling and event shape. - Add or remove
subscriptions. - Add or remove engine specific view wiring (
styleNode, event listeners, timeline attributes). - Add or remove WAAPI JavaScript and ports.
This order usually gives the cleanest compiler guided path.
Target Engine Checklists¶
Pick the engine you are migrating to and apply that checklist.
To Transition¶
Use this when you want the simplest pure Elm setup with CSS transitions.
Required changes:
- Use
Transition.init. animatereturnsAnimState.- No
subscriptionsrequired for animation flow. - Use DOM event listener pattern for events.
- Remove
Keyframe.styleNodeif coming from Keyframe. - Remove WAAPI ports and JavaScript if coming from WAAPI.
To Keyframe¶
Use this when you want pure Elm setup plus pause, resume, restart, and looping support.
Required changes:
- Use
Keyframe.init. animatereturnsAnimState.- Add
Keyframe.styleNode model.animStatein view. - No
subscriptionsrequired for animation flow. - Use DOM event listener pattern for events.
- Remove WAAPI ports and JavaScript if coming from WAAPI.
To Sub¶
Use this when you want full Elm side control and frame based updates.
Required changes:
- Use
Sub.init. animatereturnsAnimState.- Add
subscriptionswithSub.subscriptions. Sub.updatereturns( AnimState, List AnimEvent ).- Remove DOM event listener pattern (events come from
Sub.update). - Remove WAAPI ports and JavaScript if coming from WAAPI.
To WAAPI¶
Use this when you want browser native interpolation with state tracked control and optional command only triggering.
Required changes:
- Add WAAPI JavaScript companion and ports.
- Use
WAAPI.init motionCmd motionMsg .... - Add
subscriptionswithWAAPI.subscriptions. WAAPI.animatereturns( AnimState, Cmd msg ).WAAPI.updatereturns( AnimState, AnimEvent ).WAAPI.fireAndForgetreturns onlyCmd msg.- Remove DOM event listener pattern (events come via ports).
To Scroll Timeline¶
Use this when animation progress should follow container or document scroll.
Required changes:
- Remove
AnimStatebased flow (init,update,subscriptions). - Use
ScrollTimeline.animate motionCmd container buildFn. - Keep WAAPI JavaScript companion and outgoing port.
- Use
ScrollTimeline.attributes animGroupin view.
To View Timeline¶
Use this when animation progress should follow an element position in the viewport.
Required changes:
- Remove
AnimStatebased flow (init,update,subscriptions). - Use
ViewTimeline.animate motionCmd buildFn. - Use
rangeStartandrangeEndwhen needed. - Keep WAAPI JavaScript companion and outgoing port.
- Use
ViewTimeline.attributes animGroupin view.
Common Migration Traps¶
- Subscriptions missing after moving to
SuborWAAPI. - Missing
Keyframe.styleNodewhen moving toKeyframe. - Forgetting WAAPI JavaScript setup when moving to
WAAPI,ScrollTimeline, orViewTimeline.
Need Full API Details?¶
Use engine specific pages for complete references:
For end to end code, see Examples.