bootstrap-slider
bootstrap-slider copied to clipboard
Slider handle affected by the viewport position
Hello, I have created a jsfiddle of the bug I am trying to fix and wondering if you could help.
Essentially I have the slider in a modal. If the viewport has scrolled down and the modal/slider is visible the slider handles seem relative to the viewport and do not work correctly - despite they look to be in the correct position.
https://jsfiddle.net/informa/a7c6s7zn/5/
The Fiddle:
- The Buttons on the page open a bootstrap modal that contains a bootstrap slider - vertical.
- The paragraph text on the page simulates a SCROLL on the body.
- Clicking the green button opens the modal and the bootstrap slider works as expected.
- Clicking the Red button, by scrolling past the text opens the modal but the bootstrap slider handle has been affected by the page scroll position and therefore doesn't work correctly.
I faced the same issue, a quick fix is to go #L1472
offsetTop += obj.offsetTop;
And replace it by
offsetTop += obj.offsetTop - obj.scrollTop;
It will take into account the scroll of the offset parents, however, if you scroll using your mouse wheel during a slide the handle position is wrong again.
A real fix for this issue should
- Take into account any parent scroll (not only offset parents)
- Recalculate if a scroll occurred between each mousemove tick (because the scroll may have changed due to mouse wheel or anything else)
This is a huge bug for me, and the fix didn't work. I have to scroll down plenty, then use the slide.
Just found the fix for this, here . https://github.com/seiyria/bootstrap-slider/issues/308
I have similar issues while trying use a horizontal slider in a bootstrap popover.
EDIT: Scratch that, looks like it's only a problem when the Chrome dev console is open. :)