2010-08-25 104 views

回答

5

您可以設置.height()並使用startstop事件,像這樣.width()

$(".icon").draggable({ 
    start: function() { 
     $(this).height(100).width(100); //drag dimensions 
    }, 
    stop: function() { 
     $(this).height(50).width(50);  //original icon size 
    } 
});​ 

You can give it a try here,或a bit more compact

$(".icon").draggable({ 
    start: function() { 
     $(this).css({ height: 100, width: 100 }); 
    }, 
    stop: function() { 
     $(this).css({ height: 50, width: 50 }); 
    } 
});​ 
+0

我不知道http://dummyimage.com。很有用。 – user113716 2010-08-25 14:00:31

+0

太酷了,thx。最後一個問題。我想保留原始尺寸的原始圖標? – Dooie 2010-08-25 14:01:38

+0

@Dooie - 你可以設置'helper:'clone''選項,這是你在找什麼? http://jsfiddle.net/nick_craver/8QteZ/2/ – 2010-08-25 14:04:08

0

事件綁定到的dragstart和dragend,在這裏看到的樣品: Active Drag Demo (number 5)

並拖動開始與病程的圖像會更大樣式時addClass()和removeClass()拖動停止時。

+0

這是一個不同的拖動庫中,OP是具體指的是jQuery UI Draggable,在這裏找到:http://jqueryui.com/demos/draggable/ – 2010-08-25 13:54:33

相關問題