Skip to content

[BUG] Scroll Progress does not respect layout changesΒ #2718

@boar-is

Description

@boar-is

1. Read the FAQs πŸ‘‡
βœ…

2. Describe the bug

Changes to element dimensions won't trigger scroll progress. This is problematic for cases where this is forced (like calculating element's height on the client).

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-xvjyb4?file=app%2Fpage.tsx

4. Steps to reproduce

Steps to reproduce the behavior:

Go to the reproduction, refresh the result, and observe the actual behavior:

  1. Blue box's height is 50dvh, yellow's one is 0. The progress goes to 1 (nothing to even scroll)
  2. After 1.5s, yellow box's height goes to 300dvh. The progress is still 1, however, it should be 0.
  3. Scroll a bit. You'll see that the progress is recalculated to the correct value and it indeed should have been 0 initially.

5. Expected behavior

Changes to element dimensions should also trigger scroll progress recalculation.

Steps to reproduce is descriptive. Here I'll note that the only "hack" I found out for now is to setTimeout with scrollYProgress.set, which I don't like (the timeout is so indefinite and go up to 500ms).

6. Video or screenshots

N/A, see the reproduction

7. Environment details

Framer Motion 11.2.11, other's N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions