Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScrollSpy: improve active feedback #41016

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

guilhas07
Copy link

@guilhas07 guilhas07 commented Nov 7, 2024

Motivation & Context

Current ScrollSpy behavior had some shortcomings when it comes to detecting the correct active class.

  • Sometimes none of the classes are active
  • After clicking to go to a section, it immediately shows as non active

Solution

To fix this I simplified the current logic, by adding an active state for all sections and keeping track of the previous highlighted section. The current rational is to highlight the first section that is intersecting at all times.

Different logic for scrolling up or down and custom thresholds are removed due to not being needed anymore.

Note: This is a first draft, so I didn't delve deeper into all of the code that can be simplified. I would be grateful for any feedback. Thank you for your time and for this amazing project!

Changes

Scroll Behaviour:

  • Before ( Note that sometimes the active class disappears and other times it jumps to early ):
old-scroll.mp4
  • After:
new-scroll.mp4

Click Behaviour:

  • Before (Note the section clicked isn't active after auto scroll)
old-click.mp4
  • After
new-click.mp4

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactoring (non-breaking change)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • My change introduces changes to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Live Previews

https://deploy-preview-41016--twbs-bootstrap.netlify.app/docs/5.3/getting-started/introduction/

@guilhas07 guilhas07 requested a review from a team as a code owner November 7, 2024 17:22
@Manchmal1
Copy link

Was muß ich machen um die auf dem Fernseher zu sehen bitte

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.

3 participants