1

I have this div called 'header'. which is draggable and has a scroll bar. to prevent the div dragging when clicking the srollbar I have this code below, however it is not effective if the thumb is at the absolute top and someone clicks the the top arrow or scrolls up with the thumb. it will then start to drag. same thing for the bottom. How can I prevent this from happening. Thanks.

$("#header").draggable({ start: function() { if ($(this).data("scrolled")) { $(this).data("scrolled", false).trigger("mouseup"); return false; } } }).find("*").andSelf().scroll(function() { $(this).parents(".ui-draggable").data("scrolled", true); }); 
3
  • 1
    why so complex? just use 'cancel' option to disable dragging scrollbar. api.jqueryui.com/draggable/#option-cancel Commented Feb 24, 2013 at 19:11
  • I just used 'cancel' can't believe how simplified it made things. Thank you dude. Commented Feb 24, 2013 at 19:25
  • nice. i'm moving it to answer so that you can accept it :) Commented Feb 25, 2013 at 6:33

1 Answer 1

1

If you use 'cancel' option, you can solved it easily.

Please check their official doc http://api.jqueryui.com/draggable/#option-cancel

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.