Repository navigation
Add reducedMotionHandling to @wix/interact - #400
Merged
Merged
Conversation
A cascading `reducedMotionHandling` field (`ignore` | `cancel` | `collapse` | effectId) on the config, interactions, sequences and effects. Each effect position yields variants under exclusive reserved prefers-reduced-motion media, which generate() emits and the runtime picks from, so the WAAPI and CSS paths match without adding effects to the config. `Interact.forceReducedMotion` now applies the reduced outcome, with a matching generate() option. Validation, docs and the design doc (docs/reduced-motion-design.md) included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Generated
|
ameerf-wix
commented
Nov 4, 2026
…ation - reducedMotionHandling defaults to 'collapse'; collapse also takes finite iterations to one, and a sequence's stagger collapses unless it's ignored - forceReducedMotion can be set per instance via Interact.create() - handling is resolved from values, not the objects holding them; the time/scrub kind uses effectToAnimationOptions' discriminator - replacement body fields are typed against the effect types; runtime fallback warnings are dropped (the validator reports them) - CSS variants fall back only the entries assigned before their effect; an instant entrance is detected from its own duration - keyframe naming stays where it was in resolveEffectForCSS - validate: reduced-motion checks run inside the existing walks, replacement kinds come from the effect schemas, sequence definitions are reported per reference instead of deduplicated, shared helpers and modes are reused Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nal iterations - reducedMotionHandling is no longer a config field: Interact.setup() sets the default for every instance, Interact.create() options override it per instance, and generate() takes it as an option defaulting to setup()'s - forceReducedMotion is set through Interact.setup() too - collapse keeps the fraction of fractional iterations and flips `reversed` when the last alternate iteration runs backwards, so the collapsed effect ends where the full one does - the validator rejects the field on the config root and assumes the default instance handling Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-and-design # Conflicts: # CHANGELOG.md # packages/interact/src/core/Interact.ts # packages/interact/src/core/add.ts
ameerf-wix
commented
Nov 4, 2026
- reducedMotionHandling / ReducedMotionHandling are now reducedMotionPolicy / ReducedMotionPolicy everywhere, docs included - the validator's reduced-motion checks run last in each walk batch - BODY_FIELDS is a plain array again - the resolver's option and FullEffect types live in types/css.ts - keyframe naming is back before the CSS-rules check, with resolveBody at module level Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-and-design # Conflicts: # CHANGELOG.md
ydaniv
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the design in
docs/reduced-motion-design.md.reducedMotionPolicy:'collapse'(default) |'ignore'|'cancel'| effectId. It can be set on interactions, sequences and effects, and per instance; the most specific wins. The instance value isn't a config field:Interact.setup()sets it for every instance,Interact.create(config, options)overrides it for one, andgenerate()takes it as an option.collapseplays one 0ms iteration that keeps the delay and ends where the effect would (fractional iterations and backwardsalternateiterations included). Effects with no end state (looping,viewProgress,pointerMove) are cancelled. A sequence's stagger collapses too, unless its handling is'ignore'.prefers-reduced-motionmedia:generate()emits them, and the runtime picks the matching one. No effects are added to the config, so ids, slots and list entries are unchanged.forceReducedMotion(Interact.setup(),Interact.create(),generate()) applies the reduced outcome instead of passingreducedMotionto motion.@wix/interact-validate: schema for the field, plus reference, kind-compatibility and semantic checks. They run inside the existing config walks.Breaking: under OS reduce, effects now collapse by default. Opt out with
Interact.setup({ reducedMotionPolicy: 'ignore' }). With the default,forceReducedMotionkeeps its old behavior, except that finite multi-iteration animations collapse to their end state instead of being dropped.Verified with unit tests, and in Chromium / Firefox / WebKit comparing WAAPI-only against
generate()CSS underreduce/no-preference: entrances, sequence stagger, variation overrides, collapsed iteration end states, and live media toggles.🤖 Generated with Claude Code