bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

bootstrap-affix.js: using Chrome, affixed menu moves violently up and down each time one scrolls to the bottom of page

Open tim-peterson opened this issue 14 years ago • 109 comments

I'm using Chrome version 21 and Mac OS X 10.7.

I don't have this same problem on Firefox 14, Safari 6, or Opera 12.

tim-peterson avatar Aug 23 '12 18:08 tim-peterson

Did you try to style the .affix-bottom? I had a similar jumpy experience with my affixed

. Adding .affix-bottom to CSS and styling it fixed the jumping at the bottom of the page.

michalKopec avatar Aug 23 '12 21:08 michalKopec

@MichalKopec thanks, so the menu div gets the affix JS and a separate footer div gets the .affix-bottom class? might you explain in code what you mean?

tim-peterson avatar Aug 24 '12 01:08 tim-peterson

The bottom bound can fix this, yes. Also, margin on the bottom of an element can cause the jumping, so double check that.

mdo avatar Aug 27 '12 22:08 mdo

just to be clear, the behavior I observed was on the twitter bootstrap site itself, not my own html.

tim-peterson avatar Aug 28 '12 00:08 tim-peterson

@tim-peterson weird, i can't reproduce this (and i have an identical setup). What page are you seeing this on? fullscreen? etc?

fat avatar Aug 28 '12 05:08 fat

http://twitter.github.com/bootstrap/javascript.html, scroll down all the way to the bottom using Chrome 21.0.1180.82, not fullscreen.

the affix menu,<ul class="nav nav-list bs-docs-sidenav affix-bottom">, goes berserk because the classes affix-bottom and affix get toggled rapidly.

tim-peterson avatar Aug 28 '12 05:08 tim-peterson

Same issue here on a custom implementation. Classes affix and affix-bottom get toggled rapidly while scrolling (and the affixed element exceeds the desired bottom offset). Using this:

$('.title').affix({ offset: { top: 350, bottom: 1500 } })

mspivak avatar Aug 28 '12 16:08 mspivak

I'm not seeing this at all and have the same version of Chrome.

mdo avatar Aug 28 '12 17:08 mdo

maybe its just a Mac trackpad issue, i'm using OS X 10.7.4 and have my system preferences->trackpad "Tracking speed" set to the 4th tickmark out of 10 (going left to right).

Btw, sorry to keep wasting your time on this, its not a big deal to me personally but can't hurt to have a record of this issue for others.

tim-peterson avatar Aug 28 '12 17:08 tim-peterson

I am also experiencing this issue, though I am on Windows 7. I experienced this issue in Chrome and Firefox. I believe at one point I had it functioning properly but through editing further this flickering behavior began to happen. I suppose there may be an error in my code, but if it is happening to others as well perhaps there is a bug.

oxideous avatar Aug 29 '12 16:08 oxideous

I am also experiencing this issue. I'm really stuck here. I can't figure out what is going wrong. But I have an additional problem with absolute positioning. The toggling of the affix and affix-bottom classes are sequential and not random. Here's what I've found so far (and my code):

Live Example

http://phaseone.me/internets/github_issues/bootstrap/4647/prod/Printed-Tags.html

The JS

// DYNAMIC SUBNAV
// --------------
$('#subnav-list').affix({
  offset: {
    top: function() {
      brw = $(window).width();
      if (brw >= 1200) return 114;
      // Still need to include other widths
    },
    bottom: 171
  }
});

The HTML

The whole page: https://gist.github.com/3517294

Here's a screencap of the relevant section: http://grab.bovie.me/fJhS

The CSS

#subnav-list.affix-bottom {
  position: absolute;
  top: auto;
  bottom: 126px;
}
#subnav-list {
  width: 240px;
  padding: 15px;
  margin: 30px 0 0 0;
}
#subnav-list.affix {
  top: 50px;
  position: fixed
}

The other problem

Instead of the nav-list positioning itself to the page, it is somehow relevant to .subnav. Despite having the style the same as the bootstrap docs, it's positioned wrong.

With .affix-bottom:

> $('#subnav-list').offset().top
  76

With .affix:

> $('#subnav-list').offset().top
  2574

phaseOne avatar Aug 29 '12 19:08 phaseOne

@phaseOne , weird i'm not seeing this issue on your site though I'm still seeing it on the twitter bootstrap site.

tim-peterson avatar Aug 30 '12 03:08 tim-peterson

Having the same issue with custom implementation. Any updates on this issue? It would be really important for me.

laszlo-horvath avatar Aug 31 '12 13:08 laszlo-horvath

I'm having this issue as well.

tonybruess avatar Aug 31 '12 17:08 tonybruess

I figured out that the main problem is when the "affix" and "affix-bottom" CSS classes are toggled the CSS on the element are also changing aswell. And the jumpy experience caused because the top and bottom properties are changing from "auto" to a fix value.

For example in my case:

.affix { position: fixed; top: 40px; bottom: auto; } .affix-bottom { position: fixed; top: auto; bottom: 595px; }

If I give a fix value for both classes it won't jump anymore but in my case for the bottom class I would need a negative top value because my element is higher than the avalaible space I have for it in my layout. That negative top value should be calculated by the plugin..

laszlo-horvath avatar Sep 01 '12 11:09 laszlo-horvath

You guys should fix this, i have faith in you bros

fat avatar Sep 05 '12 03:09 fat

@fat since you aren't working at Twitter are you also not working on Bootstrap anymore? Regardless, what will you be up to now?

I'm just curious as someone who is eternally grateful for your and Mark's colossal contribution to the community,

tim-peterson avatar Sep 05 '12 03:09 tim-peterson

I had the same issue and i made a patch for it,

https://github.com/vaionicle/bootstrap/commit/8a74ad7b888d1f3d07845d36ddb65d0914eeec32

try it and let me know if it is working.

vaionicle avatar Sep 05 '12 14:09 vaionicle

Patch doesn't work for me. Now the nav toggles between affix-top and affix-bottom rapidly.

phaseOne avatar Sep 05 '12 15:09 phaseOne

I'm using Mac OS X 10.8.1, Firefox 15.0 and Chrome 21.0.1180.89. This patch works fine. https://github.com/kzxtreme/bootstrap/commit/be411d8256b2512b0bec1b9478c58b3618fc3806

kzxtreme avatar Sep 06 '12 14:09 kzxtreme