jQuery UI Draggable set drag size
I have a number of small icons which are draggable via jQuery w开发者_开发问答hich i clone, can i make the draggable icon larger when drag starts?
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 });
}
});
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.
精彩评论