Skip to content

useScrollTrigger: progress can go stale on resize/geometry change without a scroll #18

Description

@arzafran

Summary

In useScrollTrigger (packages/hamo/src/use-scroll-trigger/index.ts), update() is a stable useEffectEvent, and the effects that invoke it depend only on [lenis, update, ...deps]. The computed startValue / endValue depend on the element rect, window height, start/end, and offset — but a change to any of those does not re-run update(). So after a resize (or other geometry change) without a subsequent scroll, the reported progress can be stale until the next scroll / transform tick.

Surfaced by an independent cross-model (Codex) review during the v1 hardening (#12).

Important context

This is pre-existing behavior, not introduced by the v1 maintainability pass — the update effect dependency arrays are byte-identical to the original port (#11 / commit 428de5e). It is verified not a regression, so it does not affect #12's behaviour-preserving claim. Filing it so the limitation is tracked rather than lost.

Repro (conceptual)

  1. Mount a useScrollTrigger with onProgress.
  2. Resize the window (or change the element's size/position) without scrolling.
  3. onProgress does not re-fire with the recomputed start/end until the next scroll or transform update.

Options to evaluate

  • Re-run update() when startValue / endValue (or their inputs) change — e.g. add the derived values to the relevant effect's dependency array.
  • Or explicitly recompute on resize via the existing useWindowSize / useRect signals.
  • Confirm whether this is intentional (scroll-driven recompute only) — if so, document it.

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions