PDA

View Full Version : How to Handle Drag on Resizable



ch-world
22 Dec 2006, 2:42 PM
Hi,

i'm trying to use this code:


var custom = new YAHOO.ext.Resizable('tab', {
wrap:true,
pinned:false,
minWidth:50,
minHeight: 50,
dynamic:true,
handles: 'all', // shorthand for 'n s e w ne nw se sw'
draggable:true
});

custom.on('resize', function(){ alert('resized');});

But how can i handle a drag?

uofmpike
17 Jan 2007, 3:43 PM
Did you resolve this? I'm wondering the same thing.


Hi,

i'm trying to use this code:


var custom = new YAHOO.ext.Resizable('tab', {
wrap:true,
pinned:false,
minWidth:50,
minHeight: 50,
dynamic:true,
handles: 'all', // shorthand for 'n s e w ne nw se sw'
draggable:true
});

custom.on('resize', function(){ alert('resized');});

But how can i handle a drag?

JohnT
17 Jan 2007, 3:47 PM
I also cannot figure this out:

Example:
http://shopchmi.com/NOTUSED/PDI/editor.htm

I need to know whether or not they are dragging outside their "boundary". Asked on YUI forum as well, no takers.

I wish I could help, but I am in the same boat as you guys.

tryanDLS
17 Jan 2007, 3:55 PM
The current dragdrop is the YUI dragdrop, so my thought would be you have to handle the 'endDrag' (or maybe onDragDrop) event. Refer to their doc for examples if you can find anything here. Note that the Tree example is using .40 yui-ext dragdrop, which isn't available yet, so it's probably not a good example to use for how to handle the events.

brian.moeskau
17 Jan 2007, 9:35 PM
It's a regular YUI dd being used, so the method I use is like this:


dd.startDrag = function(x,y) {
// save off something to identify the object begin dragged.
// I'm saving it on the draggable object directly so that I can retrieve
// it at the end of the drag without any scope issues -- there's probably
// a better way to do this, but it works
this.evtId = evt.ID;
};
dd.endDrag = function(e) {
// retrieve the business entity via the id stored from startDrag
// and do whatever you want with it.
var evt = eventEls.get('e'+this.evtId);
view.update(this, evt);
};
This works for what I need, which is calculating a relative distance between where the drag started and where it ended. This does not have anything to do with handling a specific drop target. For that, I'd assume that you'd need to similarly handle dragDrop instead of endDrag, but I haven't needed to try that yet.

tryanDLS
18 Jan 2007, 8:10 AM
You could handle this by not allowing them to drag outside a set area to begin, using setXConstraint, setYConstraint. When they drop it, you should be able to then get the current X,Y coordinates. See the thread from late last nite, which discussed using these methods.