force dropstart to update on each mousemove

21 views
Skip to first unread message

knyttr

unread,
Apr 14, 2010, 12:13:05 PM4/14/10
to threedubmedia
Hi,

I am using your special.drop to create something like
"jquery.sortable", so I need to have function which would be called on
each mousemove when the dragged element is over element with
special.drop. "Dropstart" would be great if it was called on each
mousemove.

Is that supported by the plugin or is it necessary to tamper with the
source?

Thanks.

V. K.

Sahab Yazdani

unread,
May 6, 2010, 3:48:41 PM5/6/10
to threedubmedia
This is supported, and actually works very well, but it takes a fairly
deep understanding of both the drag *and* drop plug-in. Basically what
you need to do is to provide your own tolerance mode function (look at
the modes object in the jquery.event.drop source file) and return null
instead of a "best". The plug-in will call that tolerance function for
every drop target you've specified so the logic to determine the real
drop target becomes a bit complicated. I can fill you in on some of
the nitty gritties over e-mail.
--
You received this message because you are subscribed to the Google Groups "threedubmedia" group.
To post to this group, send email to threed...@googlegroups.com.
To unsubscribe from this group, send email to threedubmedi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/threedubmedia?hl=en.

3wme

unread,
May 6, 2010, 4:44:54 PM5/6/10
to threedubmedia
In the new version of the drag and drop events, which will be released
soon, this is supported by looking at the drop target event property
within the "drag" handler. That way you can determine as often as
every mousemove, which drop targets are active at any time. To make it
work in the current version, as Sahab suggested, you can use a custom
tolerate function, but this is pretty complex. I think it is much
easier to accomplish using closures and your own custom event, kind of
like this:

// hold the active drop targets
var $active = $([]);
// bind drop event handlers
$('table td')
.bind("dropstart",function(){
$active = $active.add( this );
$( this ).addClass("active");
})
.bind("dropend",function(){
$active = $active.not( this );
$( this ).removeClass("active");
})
.bind("drop dragover",function( ev ){
$('#log').append('<li>"'+ ev.type +'" #'+ $( this ).text() +'</
li>').scrollTop(9e5);
});
// bind drag event handlers
$('.drag')
.bind("drag",function( ev ){
$active.triggerHandler("dragover");
$( this ).css({
top: ev.offsetY,
left: ev.offsetX
});
});

http://jsbin.com/iheja3
Reply all
Reply to author
Forward
0 new messages