Question

I was trying to understand how to change the value of a knob without click and drag but with a mouseover event.

Something like if the knob's handle follows the mouse.

here my fiddle.

http://jsfiddle.net/salvonostrato/dJ35f/1/

How can I do this?

I have tried with no results:

$('input.infinite').mouseover(function () {
        $("input.infinite").knob({
            'change': function (v) {
                if (val > v) {
                    if (up) {
                        decr();
                        up = 0;
                    } else {
                        up = 1;
                        down = 0;
                    }
                } else {
                    if (down) {
                        incr();
                        down = 0;
                    } else {
                        down = 1;
                        up = 0;
                    }
                }
                val = v;

            }
        });
    });

Thanks

Was it helpful?

Solution

you can try to trigger mousedown on mouseenter and mouseup on mouseleave like this

$(function () {
    var $knob=$(".infinite").knob();
    $knob.mouseenter(function () {
        $knob.children("canvas").trigger("mousedown");
    }).mouseleave(function(){
        $knob.children("canvas").trigger("mouseup");
    });    
});    

http://jsfiddle.net/dJ35f/2/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top