Repository navigation
fix(interact): honor selector conditions on viewProgress and pointerMove - #344
Merged
Merged
Conversation
ameerf-wix
approved these changes
Oct 21, 2026
eliranhe
marked this pull request as ready for review
October 21, 2026 14:27
eliranhe
enabled auto-merge (squash)
October 22, 2026 06:13
Contributor
Author
|
#skipreview |
core/add.ts resolves an effect's `selector` condition and passes it to every trigger handler as `selectorCondition`. click, hover, viewEnter and animationEnd skip a target that doesn't match it, and the CSS that generate() writes is scoped by it too. viewProgress and pointerMove ignored it: every target got the scroll-driven animation or the pointer effect, so an effect meant for part of a list (e.g. every other repeater item) ran on all of them. Return early from both handlers when the target doesn't match. Scrub effects have no per-event callback to check in, so the check runs once, when the handler is added, before the animation, scroll scene or Pointer is created. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eliranhe
force-pushed
the
fix/scrub-triggers-selector-condition
branch
from
October 22, 2026 06:19
9c7b0d8 to
5f18c39
Compare
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.
Description
Bug fix:
viewProgressandpointerMoveignore an effect'sselectorcondition.core/add.tsresolves the effect'sselectorcondition and passes it to every trigger handler asselectorConditioninInteractOptions.click,hover,viewEnterandanimationEndskip a target that doesn't match it (if (selectorCondition && !target.matches(selectorCondition)) return;), and the CSS thatgenerate()writes is scoped by it too.viewProgressandpointerMovenever read it. Every target got the scroll-driven animation or the pointer effect, so an effect meant for part of a list (e.g. every other repeater item) ran on all of them.Fix: both handlers now read
selectorConditionand return early when the target doesn't match. Scrub effects have no per-event callback to check in (they're driven continuously by the ViewTimeline / fizbanScroll/ kulisoPointer), so the check runs once, when the handler is added:viewProgress: nogetWebAnimationanimation (nativeViewTimeline) orgetScrubScene+Scroll(fizban polyfill) is created or played for a non-matching target.pointerMove: nogetScrubScene+Pointeris created for a non-matching target.Related Issue
Found while generating interact configs for Wix sites in the Thunderbolt viewer, which expresses repeater "pattern" effects as an effect-level selector condition, e.g.
The CSS from
generate()honors it, but the scroll and pointer effects ran on every repeater item. Thunderbolt currently works around this by folding the pattern into the effect'sselector. That workaround can be removed once a release with this fix is bumped downstream.Checklist
rules/full-lean.mdalready says a selector condition on an effect skips only that effect, and this makes the two scrub triggers behave that way.Tests
Three new specs in
test/mini.spec.ts›selector condition type›scrub triggers on a list (repeater pattern). Each builds a 4-item[role="list"]withlistContainerand a:nth-child(2n)selector condition:ViewTimeline: animations are created and played only for items 2 and 4Scrollinstances only for items 2 and 4Pointerinstances only for items 2 and 4Without the fix, all three fail with
expected "vi.fn()" to be called 2 times, but got 4 times. With it,yarn workspace @wix/interact testpasses (494/494).tsc --noEmit, eslint and prettier are clean on the changed files.Additional Notes
&predicate: jsdom's selector engine (nwsapi 2.2.23) throws on&inElement.matches()and mis-evaluates:scopethere, so the Thunderbolt-shaped predicate can't run in the unit tests. The specs use:nth-child(2n)on the list items, which goes through the sametarget.matches(selectorCondition)gate. In a real browser (Chrome 152), on four items nested in a[role="list"],item.matches('[role="list"] > :nth-child(2n) &')returns[false, true, false, true].&: a predicate that uses&depends on the browser resolving a top-level&inmatches(), which comes with CSS Nesting support. Engines without it throw aSyntaxError. That was already true for the other handlers, but those throw inside an event callback; here it would throw fromadd().🤖 Generated with Claude Code