Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !15593

Handle multiple zero-offset Scrollspy elements.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/neoeno/handle_multiple_zero_offset_scrollspy_elements into master Jan 17, 2015
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 2

Created by: neoeno

When the first two elements tracked by Scrollspy have an offset.top of 0, Scrollspy will flip between activating their respective nav events on every scroll event. This causes a visual 'flicker', and heavily degrades scroll performance.

Examples: Minimal example. Example with nested sections.

I saw this happen in a system of nested sections positioned hard against the top of the document, e.g.

<section id="animals">
  <section id="dogs">
    Content
  </section>
</section>

The bug is that Scrollspy's check to see if it's at the end of the array of sections uses !arr[index + 1]. This misses the case where arr[index + 1] does exist and is zero.

This commit explicitly checks the array bounds. A unit test is included, but I'm not familiar with bootstrap's testing approach so feedback is appreciated.

(Thanks go to @theroux and @tnguyen14!)

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/neoeno/handle_multiple_zero_offset_scrollspy_elements