आपको ट्रैक करने की आवश्यकता है कि कौन से तत्व ड्रैजेंटर और खींचें पर चालू किया गया था। एक व्यक्तिगत तत्व पर ड्रैगेंटर और ड्रैगलीव को सुनना न केवल उस तत्व की घटनाओं को बल्कि बच्चों पर होने वाली घटनाओं को भी कैप्चर करेगा।
$.fn.draghover = function(options) {
return this.each(function() {
var collection = $(),
self = $(this);
self.on('dragenter', function(ev) {
if (collection.length === 0) {
self.trigger('draghoverstart');
}
collection = collection.add(ev.target);
});
self.on('dragleave drop', function(ev) {
collection = collection.not(ev.target);
if (collection.length === 0) {
self.trigger('draghoverend');
}
});
});
}; इवेंट के लिए सुनें -
$(window).draghover().on({
'draghoverstart': function() {
alert(‘dragged into the window');
},
'draghoverend': function() {
alert('dragged out of window');
}
});