bootstrap-slider icon indicating copy to clipboard operation
bootstrap-slider copied to clipboard

Slider isn't positioned correctly if first tick isn't at zero position

Open phazei opened this issue 9 years ago • 6 comments
trafficstars

$(document).ready(function () {
    var mySlider = $("#slider-input").slider({
        ticks: [10, 100, 200, 400],
        ticks_positions: [10, 50, 70, 90],
        ticks_labels: ['$10', '$100', '$200', '$400'],
        ticks_snap_bounds: 30
    });
});

$10 should be at 10% and $400 should be at 90% Everything should scale in between, but the first value will jump to 0%

The $10 tick is correctly positioned, and if you use the arrow keys to slowly move the value down, it will go 14, 13, 12, 11, all where you'd expect them, just in front of the $10 tick, but the moment you get to $10, the slider-handle jumps to 0% position http://plnkr.co/edit/patfGe?p=preview

phazei avatar Feb 19 '16 04:02 phazei

For this particular use it's a static slider with a fixed value, so I found this hack fixed it enough to suite my purposes, though if the slider was not disabled, the left value would be weird:

    ticks="[-0.0001, 0, invite.referrals.accepted>10?invite.referrals.accepted:10]"
    ticks-positions="[5, 5, 95]"
    ticks-labels="['', '0% Off', '100%']"

The -0.00001 jumps to the very left, so the 0 actually shows up where expected, there's an extra tick behind it, but it has no value so no harm. Wish I had time to look into it further for a proper fix. Great slider by the way, I'm actually using the angular directive for it, works nicely.

(Though I did find another bug that's really minor, if the max tick is set to say 10, then later changed to 20, the aria-valuenow won't ever go above 10. Not affecting me enough to do anything about it though)

phazei avatar Feb 19 '16 04:02 phazei

feel free to submit a PR with a fix + automated test coverage. Thanks!

rovolution avatar Feb 19 '16 23:02 rovolution

I still have no idea how to fix this other than the hack. Just wanted to confirm it's still occurring in 7.1.1

phazei avatar Jul 08 '16 18:07 phazei

Still in 9.8.0. Updated the plunker http://plnkr.co/edit/patfGe?p=preview

Still don't know what's causing it. Any ideas? I'm using it in a dynamic slider situation, so the work around that visually fixes it doesn't work.

phazei avatar May 25 '17 23:05 phazei

Any progress on this one?

6matko avatar Feb 01 '18 16:02 6matko

no, but we would appreciate a PR!

rovolution avatar Feb 02 '18 15:02 rovolution