Martin Scheffler
2005-Dec-03 13:37 UTC
dragdrop patch that enables dragging from and to divs with overflow:scroll
Hi all, this is a patch for 1.5_rc5
I noticed that I was not able to drag stuff out of scrolling divs. When I tried
to drag it out, the draggable would remain in that div and the scrollbars would
adapt to the bigger content of the div.
This patch extends draggable with an option :tofront. When it is set to true,
the draggable will be moved to the document body while keeping its position on
the page. This enables dragging it out of the div. At the moment it only works
with ghosting and revert, because I can''t be bothered to test the other
modes just yet.
Have fun
141c141
< reverteffect: (function(element, top_offset, left_offset) {
---> reverteffect: function(element, top_offset, left_offset) {
143,166c143,144
< new Effect.MoveBy(element, -top_offset, -left_offset,
< {duration:dur,
< afterFinish:(function(){
<
< if(this.onFront) {
< this.onFront=false;
<
<
this._clone.parentNode.insertBefore(this.element,this._clone);
<
this.element.style.left=this._clone.offsetLeft+"px";
<
this.element.style.top=(this._clone.offsetTop-this._clone.parentNode.scrollTop)+"px";
<
< Position.relativize(this.element);
<
< if(this.options.ghosting) {
<
< Element.remove(this._clone);
< this._clone = null;
< }
<
< }
<
< }).bind(this)
< });
< }).bind(this),
---> new Effect.MoveBy(element, -top_offset, -left_offset,
{duration:dur});
> },
227,229c205
< if(this.onFront) {
< return;
< }
--->
253c229
< if(this.options.ghosting && !this.options.bringtofront) {
---> if(this.options.ghosting) {
302d277
<
345c320
< if(this.options.ghosting && !this.onFront ) {
---> if(this.options.ghosting) {
350,367d324
< if(this.options.bringtofront && !this.onFront) {
< this.onFront=true;
< pos=Position.page(this.element);
<
< this.originalLeft = pos[0];
< this.originalTop = pos[1];
< this.originalZ=1000;
< document.body.appendChild(this.element);
<
< var pointer = [Event.pointerX(event), Event.pointerY(event)];
<
< this.offsetX = (pointer[0] - pos[0]);
< this.offsetY = (pointer[1] - pos[1]);
<
< this.element.style.left=pos[0]+"px";
< this.element.style.top=pos[1]+"px";
<
< }
______________________________________________________________________
XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club!
Jetzt gratis testen! http://freemail.web.de/home/landingpad/?mc=021130
