Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@tuzixiangs
Copy link
Contributor

  • Add currentTargetHref to track active scroll target
  • Ignore duplicate clicks on same anchor during animation
  • Prevent unnecessary animation restarts causing visual stutter

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow contributing guide English | (中文 | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer to relative issues for your PR.

Related Issues

Closes #22963

Problem

When users rapidly click the same anchor link multiple times, the scroll animation would be canceled and restarted repeatedly, causing visual stuttering and poor user experience.

Root Cause: The current implementation calls clearAnimate() to cancel the previous animation but immediately creates a new animation regardless of whether the target is the same. This causes unnecessary animation restarts when clicking the same link.

Solution

Introduced a currentTargetHref variable to track the target of the currently active scroll animation:

  • If a click targets the same anchor as the active animation → Ignore the click
  • If a click targets a different anchor → Cancel old animation and start new one
  • When animation completes → Reset currentTargetHref to empty string

- Add currentTargetHref to track active scroll target
- Ignore duplicate clicks on same anchor during animation
- Prevent unnecessary animation restarts causing visual stutter
@github-actions
Copy link

github-actions bot commented Nov 29, 2025

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 29, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/element-plus/element-plus@22964

commit: f47af1c

@github-actions
Copy link

🧪 Playground Preview: https://element-plus.run/?pr=22964
Please comment the example via this playground if needed.

@Dsaquel Dsaquel merged commit 1adf09b into element-plus:dev Nov 30, 2025
17 checks passed
@github-actions
Copy link

@tuzixiangs Thanks for your contribution! ❤️

@element-bot element-bot mentioned this pull request Dec 5, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Component] [anchor] [components] [anchor] Anchor scroll animation stutters on rapid clicks of the same link

3 participants