jslider icon indicating copy to clipboard operation
jslider copied to clipboard

Click on track to change slider value

Open chrisjhill opened this issue 12 years ago • 7 comments

Hello, is it possible to click on any part of the slider's track, and the slider value will then update? jQuery UI does this (I know this isn't UI, but heh).

Thank you!

chrisjhill avatar Jan 04 '13 13:01 chrisjhill

Vote for this issue. It will be great possibility.

rando avatar Jan 08 '13 10:01 rando

Yes, It will be really great to get this feature and I'm waiting for this.

Thanks for this great plugin!

itsanmax avatar Feb 13 '13 14:02 itsanmax

vote

MaximOrlovsky avatar Feb 19 '13 07:02 MaximOrlovsky

Hey guys,

I was aving this kind of issue and this is what I've quickly did to overcome that:

$(".layout-slider").mouseup(function(e){
    var slide_settings = $("#myslider").slider().settings ;
    var steps = $(this).width() / slide_settings.scale.length;
    var step_to_chose = slide_settings.from + (Math.round(e.offsetX / steps) * slide_settings.step) ;
    $("#SliderClothes").slider("value",step_to_chose);
 });

Basically you catch the click position into the zone and you're ready to go (check your padding zone). It's experimental but if it can help.

Cheers!

jeremypele avatar Mar 15 '13 11:03 jeremypele

Vote, Was actually looking for this feature and after going through the code, checking the Issues list was the first thing I did.

amyth avatar Aug 17 '13 13:08 amyth

waiting for it. @jeremypele 's method has an effect on drag event. My method is to cacalate the diff time between mouse down and mouse up event to detect the event is
a drag or click.

    var timeDiff = 0;
    $('.js-jslider-wrap').mousedown(function() {
        timeDiff = +new Date();
    }).mouseup(function(){
        timeDiff = +new Date() - timeDiff;
    });

    $(".js-jslider-wrap").click(function(e){
        if (timeDiff > 500) return; // drag
        // click event,  jeremypele's method go here.
    });

haledeng avatar Apr 20 '16 07:04 haledeng

another problem is that e.offsetX is the relative distance of current mouse positoin and the e.target 's position (not the position of element. As jslider add four element into DOM)

haledeng avatar Apr 20 '16 08:04 haledeng