Search code examples
jqueryjquery-knob

jQuery Knob plugin, stop repeating animations (slideDown, slideUp)


I use the knob plugin. jsFiddle It worked greatly till I added the following code to change values on hover (line 327):

.bind( "mousemove"
       , function (e) {
           e.preventDefault();
           s._xy()._mouse(e);
         }
)

I need to show this after user clicks (release function) the dial:

<div class="tooltip">Tooltip...</div>

line 673:

$(".dial").knob({
    'release': function ()
    {
        $(".tooltip").slideDown();
        $(".tooltip").delay(1500).slideUp();
    }
});

But it keeps repeating after clicking the dial. Slides down and up every 1,5 sec. I want to stop it from repeating. How to fix it?


Solution

  • You need to add a new handler, _move. Since the behavior of _mouse is for click events.

    .bind("mousemove", function (e) {
        e.preventDefault();
        s._xy()._move(e);
    })
    

    this._move = function (e) {
        var v = s.xy2val(e.pageX, e.pageY);
    
        if (v == s.cv)
          return;
    
        if (s.cH && (s.cH(v) === false))
          return;
    
        s.change(v);
        s._draw();
    };
    

    See it here.