YUI: DragDrop & Resize a Panel
In response to this
YDN-Javascript thread
The Javascript
YAHOO.example.DDResize = function(panelElId, handleElId, sGroup, config) { this.panel = YAHOO.util.Dom.get(panelElId); YAHOO.example.DDResize.superclass.constructor.call(this, handleElId, sGroup, config); }; YAHOO.extend(YAHOO.example.DDResize, YAHOO.util.DragDrop, { onMouseDown: function(e) { var panel = this.panel; this.startWidth = panel.offsetWidth; this.startHeight = panel.offsetHeight; this.startPos = [YAHOO.util.Event.getPageX(e), YAHOO.util.Event.getPageY(e)]; }, onDrag: function(e) { var newPos = [YAHOO.util.Event.getPageX(e), YAHOO.util.Event.getPageY(e)]; var offsetX = newPos[0] - this.startPos[0]; var offsetY = newPos[1] - this.startPos[1]; var newWidth = Math.max(this.startWidth + offsetX, 10); var newHeight = Math.max(this.startHeight + offsetY, 10); var panel = this.panel; panel.style.width = newWidth + "px"; panel.style.height = newHeight + "px"; } }); YAHOO.util.Event.onDOMReady(function() { var dd1 = new YAHOO.util.DD('a', 'move'); dd1.setHandleElId('b'); var dd2 = new YAHOO.example.DDResize('a', 'c', 'resize'); });