danialfarid/angular-file-upload — pull request #130 by tristan (2014-02-12 16:14:41+00:00)
Title: cancel brief removal of the dragover class when the event target changes

I found a small bug when animations where triggered upon adding the dragover class. As you move the mouse over child elements of the ng-file-drop element the dragleave event is fired, followed by a new dragover event. This can cause the animation attached to the dragover class to be triggered again, which is generally undesirable (for my example it even causes a build up of unprocessed dragover and dragleave events that take a while to process (e.g. when finally dropping the file it takes time to get through all the events and finally remove the dragover class).

The fix is to simply tell the dragover event to cancel any pending removals of the dragover class. My fix works because the dragover event that will follow the dragleave event is already queued up to be processed after the dragleave event, and the $timout call queues up the removal of the class to happen after all pending events are processed, thus if the dragover event is in the queue it will cancel the removal of the class.

I've made a demo to try show this bug here: http://plnkr.co/QqxKMCsC3Xq6L64FWiZZ if you quickly drag file over the boxes you can often see the animated overlay bouncing/flickering (it's sometimes very subtle). here is the same demo with my changes http://plnkr.co/LXqS64wWEmyG3tD4xusT which doesn't suffer from this (NOTE: firefox seems to not have the issue, but it's visible on chrome and safari).