[ACCEPTED]-jQuery Draggable and overflow issue-drag-and-drop
I had a similar problem enabling a drag 3 between two overflow-auto divs. With the 2 help of the previous answers, I found that 1 this combination works for me (Safari 5.0.3, jquery-1.4.4, jquery-ui-1.8.7):
appendTo: 'body',
containment: 'window',
scroll: false,
helper: 'clone'
appendTo
Element, SelectorDefault:'parent'
The 6 element passed to or selected by the appendTo 5 option will be used as the draggable helper's 4 container during dragging. By default, the 3 helper is appended to the same container 2 as the draggable.
Code examples Initialize 1 a draggable with the appendTo option specified.
$('.selector').draggable({ appendTo: 'body' });
It certainly pays to pay attention to the 3 documentation
http://docs.jquery.com/UI/Draggable#option-scroll
scroll
Type: Boolean
Default:true
If set totrue
, container 2 auto-scrolls while dragging.
All who enter 1 here, learn from my mistake, RT(F)M!!!
The clone solution it works, but has two 8 problems.
First: the clone are append to 7 the body. Depending of your css, your element 6 can change the styles, since before it starts, it's 5 inside of another element and during the 4 dragging, it will be directly on body element.
Second: Sometimes 3 the element MUST move, and the clone let 2 the object there.
So, the solution for this 1 problems is:
$('.selector').draggable({
helper: 'clone',
start: function(){
$(this).hide();
},
stop: function(){
$(this).show()
}
});
Setting the scroll option does not stop 4 children from being hidden in the overflow 3 area. I have come up with a work-a-round 2 that uses the helper option. Check it out:
http://pastebin.me/164f0a4073496563fe3179ddcec5fd6d
Also 1 here is a reference to another post I made:
jquery ui draggable elements not 'draggable' outside of scrolling div
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.