views:

13

answers:

2

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
This is a different dragging library, the OP is referring specifically jQuery UI Draggable, found here: http://jqueryui.com/demos/draggable/
Nick Craver
+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
I didn't know about http://dummyimage.com. Very useful.
patrick dw
That is sooo cool, thx. One last question. I want to leave the original icon in place with the original dimensions?
Dooie
@Dooie - You can set the `helper: 'clone'` option, is this what you're looking for? http://jsfiddle.net/nick_craver/8QteZ/2/
Nick Craver
you *... thanks!
Dooie