- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to detect the dragleave event in Firefox when dragging
outside the window with HTML?
You need to track which elements dragenter and dragleave had been triggered on. Listening dragenter and dragleave on an individual element will capture not only events on that element but also events on children.
$.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'); } }); }); };
Listen for events −
$(window).draghover().on({ 'draghoverstart': function() { alert(‘dragged into the window'); }, 'draghoverend': function() { alert('dragged out of window'); } });
Advertisements