Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cancel brief removal of the dragover class when the event target changes #130

Merged
merged 1 commit into from
Feb 12, 2014

Conversation

tristan
Copy link
Contributor

@tristan tristan commented Feb 12, 2014

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.

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).

danialfarid added a commit that referenced this pull request Feb 12, 2014
cancel brief removal of the dragover class when the event target changes
@danialfarid danialfarid merged commit 4893b4b into danialfarid:master Feb 12, 2014
@tristan
Copy link
Contributor Author

tristan commented Feb 13, 2014

it's essentially a noop.
https://github.com/angular/angular.js/blob/master/src/ng/timeout.js#L76

On Wed, Feb 12, 2014 at 10:56 PM, danialfarid notifications@github.comwrote:

Thanks,
If the cancel is null would the $timeout.cancel(cancel) throw error or it
is noop?

Reply to this email directly or view it on GitHubhttps://github.com//pull/130#issuecomment-34922855
.

@danialfarid
Copy link
Owner

Fixed in version 1.2.8

@rayshan
Copy link

rayshan commented Mar 31, 2014

The problem is still there with Chrome 34.0.1847.92 beta-m and angular-file-upload 1.3.1. More info on the problem here: http://stackoverflow.com/questions/7110353/html5-dragleave-fired-when-hovering-a-child-element

Perhaps add a shared scope boolean variable ngHovered, so one can ngShow/ngHide the child elements?

@danialfarid
Copy link
Owner

So is it only happening for the beta version? The stable version of chrome works?

@rayshan
Copy link

rayshan commented Mar 31, 2014

Tested the below (all in Windows, can try Mac later when I get home):
Chrome Stable 34.0.1847.92 m 👎
Chrome Beta 34.0.1847.92 beta-m 👎
IE 11.0.9600.16521 👍
Firefox 28.0 👍

@danialfarid
Copy link
Owner

Could you explain more what exactly the problem is and create a plnkr or jsfiddle for it?
I tested the original bug with angular-file-upload 1.3.1 and everything seems to be working fine:
http://plnkr.co/edit/WacBZ79gnCFGKfjgRZlL
on Chrome 33.0.1750.154 m which shows as the latest version for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants