Skip to content

fix(lint): recognize gsap.fromTo initial state in overlay-visibility check#2088

Open
miguel-heygen wants to merge 1 commit into
mainfrom
fix/gsap-fromto-fullscreen-overlay-lint
Open

fix(lint): recognize gsap.fromTo initial state in overlay-visibility check#2088
miguel-heygen wants to merge 1 commit into
mainfrom
fix/gsap-fromto-fullscreen-overlay-lint

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

gsap_fullscreen_overlay_starts_visible false-positives on a full-frame overlay that fades in via gsap.fromTo(el, {opacity:0}, {opacity:1}, 0) at t=0, when that element is later hidden again (e.g. an outro fade or a hard-kill tl.set). The overlay genuinely starts hidden, but the rule flags it as starting visible and asks the author to redundantly add opacity: 0 in CSS on top of the fromTo call.

Why

GsapWindow.propertyValues is populated from animation.properties, which for a fromTo(el, fromVars, toVars, pos) call only reflects toVars — the destination state, not the starting state. The rule's startsHiddenAtZero check inspected propertyValues at position 0, so for a fade-in fromTo it saw the destination (opacity: 1) instead of the true t=0 state (opacity: 0), and never recognized it as "starts hidden." The parser already parses fromVars separately into animation.fromProperties, but GsapWindow had no field for it and nothing read it.

The misfire was conditional: a bare fromTo fade-in with nothing else hiding the element later didn't trigger the rule (a separate guard suppressed it), but it did trigger once the element was hidden again later in the timeline.

How

  • Added a fromPropertyValues field to GsapWindow, populated from animation.fromProperties in extractGsapWindows.
  • Added a windowStartStateValues helper that returns fromPropertyValues for fromTo windows (falling back to propertyValues if absent) and propertyValues otherwise.
  • Updated startsHiddenAtZero to check the window's true start state instead of always checking the destination.
  • Checked the sibling makesOverlayVisible/isSceneBoundaryExit checks for the same blind spot — they intentionally use the destination state (correct for "does this tween end in a visible/hidden state"), so no change was needed there.

Test plan

  • Unit tests added: a bare fromTo fade-in at t=0 (no finding), and the regression case — fromTo fade-in at t=0 plus a later hide (previously flagged, now correctly not flagged).
  • bun run test in packages/lint — all 349 tests pass, no regressions.
  • bun run typecheck in packages/lint — clean.
  • oxlint / oxfmt --check on changed files — clean.

…check

gsap_fullscreen_overlay_starts_visible only looked at a tween's destination
values (toVars) when deciding whether an element starts hidden at t=0. For
a fromTo() call this destination is the wrong state to check — a
fromTo(el, {opacity:0}, {opacity:1}, 0) fade-in genuinely starts hidden,
but its propertyValues only captured opacity:1, so the rule treated it as
starting visible. This misfired specifically when the element was later
hidden again (e.g. an outro fade), since a guard that otherwise suppressed
bare fromTo entrances no longer applied once a later hide was detected.

Thread the parser's existing fromProperties (fromTo's "from" vars, already
parsed but previously unused by this rule) onto GsapWindow as
fromPropertyValues, and prefer it over propertyValues when checking a
window's start state.
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