Skip to content

[BUG] - broken layoutId animation with Next.js page change and scroll #2006

@ValentinH

Description

@ValentinH

Describe the bug

We are using layoutId to animate a current link indicator in our navbar (using fixed positioning) in a Next.js app. The animation works as expected during page navigation except when the page is scrolled. In that case, the initial position of the animation seems to be affected by the scroll offset. See this video:

framer-motion-issue.mov

Steps to reproduce

Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/p/sandbox/adoring-albattani-qtdt3b?file=%2Fsrc%2FLayout.tsx
  2. Scroll the page
  3. Click on the "Page 1" link
  4. The animation is incorrect

Expected behavior

The animation should work regardless of the scroll.

Environment details

  • MacOS 13.2.1
  • Chromium 110, Firefox 110 and Safari 16.3
  • framer-motion: 10.2.4

Similar issues

This issue seems similar to #1580 but I created a new one because I'm not fully sure that's the same issue. Feel free to tell me to close this one and comment there. 🙏

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