user3715293
user3715293

Reputation: 55

If element is dragged and get position

Heyho!

I've build a slider with the dragdealer.js plugin. Does anybody know how I can detect when my slider is dragged?

I want something like this:

if ($('element')isDragged) {
  if($('element').isAtThePosition()
  // I hope you get my idea
}

This is just my idea. At the moment my slider is working with "mousemove".

$('.slider').mousemove(function(){
  if($('.slider').position().left >= 0 && $('.slider').position().left <= 20) {
    // do something
}
})

But mousemove is not working perfect, besides my slider is really slow in firefox (but works perfectly in other browsers).

Any ideas how I could change my slider, so it would be faster in firefox?

Thank you :)

Upvotes: 1

Views: 76

Answers (1)

peacer212
peacer212

Reputation: 955

I think you could specify that directly when creating the Dragdealer element within the animationCallback

$(function() {

    var cb=function(percent) {
        if(percent>=0 && percent<=20) 
           // Do something
    };

    new Dragdealer('sliderel', {
        animationCallback: function(x, y) {
          var percent=Math.round(x * 100);
          cb(percent);
        }
    });
});

Hope that helps!

Upvotes: 2

Related Questions