Reputation: 311
following exactly the example from getting started
when the div goes outside the window the document scrool this is ok
I tried to initialize with this option from api documentation
$( function() {
$( "#draggable" ).draggable({scroll:false});
} );
The div still scroll the document. Is it a jquery bug ?
I thankyou for any suggestion but I don't like to use workaround such as put container to wrap the area. The user must be able to move the div without scrolling the document.
Upvotes: 0
Views: 75
Reputation: 325
You can use this code:
$( window ).mousemove(function( event ) {
var $el = $('#draggable');
var $window=$( window ).height();
var $bottom = $el.position().top + 100 ;
var $top = $window - 100;
if ($bottom > $window ){
$('#draggable').css({ top: $top });
}
});
jsfiddle example: https://jsfiddle.net/mr_seven/bcrx2gnj/32/
Upvotes: 1