albertogasparin/Optiscroll

Scrollbar bug caused by scrollintoView()

henryruhs opened this issue · 5 comments

  1. A carousel that is using scrollIntoView() that cannot be deactived
  2. A Optiscroll on top of that carousel

Please checkout this fiddle: http://jsfiddle.net/ty4ca48z

Comment in the last line to enable the weird scrollbar bug.

You now can enable and disable one of the following inline styles with Firebug and the bug disappears.

element.style {
    bottom: -13px;
    overflow: scroll;
    right: -13px;
}

Update: It seem like the margin on .pf-item-overview is causing this issue!

Please checkout this fiddle: http://jsfiddle.net/ty4ca48z/1/

Any idea how Optiscroll can prevent issues with such a buggy / negative scroll offset?

Apparently, scrollIntoView scrolls the main element up weirdly, even if it has overflow: hidden.
By adding this line after calling scrollIntoView you can revert the hidden scroll position back to 0:

document.getElementById('scroll').scrollTop = 0;

I would be curious to know why browser internal method feels the need of moving the container's scroll up... Moreover, it looks like it is doing it recursively: also JSFiddle page moves up 😕
Really weird.

Haha, well I spend hours to point out what is going on here, thanks for the suggestion.

Ok, I will close this one because there is nothing Optiscroll could do to prevent it.

Thank you, the scrollTop fix worked for my project...

Nice 😉