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
  • Issues
  • #16449
Closed
Open
Issue created May 08, 2015 by Administrator@rootContributor

v3.3.4: Affix plugin has problems handling items with offsetTop = 0

Created by: rafalp

Background

I have custom navbar in my app. Depending on configuration this navbar is either located at top of page, or its below user set header.

Issue

If there's element taking height above affixed one, everything works, however if affix element is at top of page, click events will switch it between affix/affix-top.

This is because if affix isn't affixed and its offsetTop is 0, following line in getState will change it to 'top':

if (offsetTop != null && scrollTop <= offsetTop) return 'top'

Next click event will trigger getState again, this time changing state back off:

if (offsetTop != null && this.affixed == 'top') return scrollTop < offsetTop ? 'top' : false

Temporary fix

I have managed to fix this issue, by changing offsetTop to 1 if navbar has no element obove it (and making existing logic work).

Proposed fix

because offsetTop == 0 is edge case, getState may check for it via running following check before all other checks:

if (offsetTop === 0) return scrollTop === 0 ? 'top' : false
Assignee
Assign to
Time tracking