I have a number of small icons which are draggable via jQuery which i clone, can i make the draggable icon larger when drag starts?
A:
Bind events to dragstart and dragend, see sample here: Active Drag Demo (number 5)
And addClass() when dragging start with styles that couse image will be bigger, and removeClass() when drag stops.
killer_PL
2010-08-25 13:49:49
This is a different dragging library, the OP is referring specifically jQuery UI Draggable, found here: http://jqueryui.com/demos/draggable/
Nick Craver
2010-08-25 13:54:33
+1
A:
You could set the .height()
and .width()
using the start
and stop
events, something like this:
$(".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, or a bit more compact:
$(".icon").draggable({
start: function() {
$(this).css({ height: 100, width: 100 });
},
stop: function() {
$(this).css({ height: 50, width: 50 });
}
});
Nick Craver
2010-08-25 13:50:08
That is sooo cool, thx. One last question. I want to leave the original icon in place with the original dimensions?
Dooie
2010-08-25 14:01:38
@Dooie - You can set the `helper: 'clone'` option, is this what you're looking for? http://jsfiddle.net/nick_craver/8QteZ/2/
Nick Craver
2010-08-25 14:04:08