Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

refactor($animate): use CSS3 transition/animation events instead of $timeouts to track ongoing animations #3882

Merged
merged 1 commit into from
Sep 6, 2013

Conversation

matsko
Copy link
Contributor

@matsko matsko commented Sep 5, 2013

Closes #3629
Closes #3874


//but some still use vendor-prefixed styles
var vendorAnimationProp = $sniffer.vendorPrefix + 'Animation';
var vendorTransitionProp = $sniffer.vendorPrefix + 'Transition';
var vendorAnimationEvent = $sniffer.vendorPrefix + 'AnimationEnd';
var vendorTransitionEvent = $sniffer.vendorPrefix + 'TransitionEnd';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a little more complicated than this. WebkitTransitionEnd is not the correct name. The vendor prefixed events seem to be: webkitTransitionEnd, oTransitionEnd, otransitionend, and MSTransitionEnd.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSTransitionEnd doesn't seem to be in use. This makes sense since IE10 doesn't require a -ms- prefix. http://msdn.microsoft.com/en-us/library/ie/hh673535(v=vs.85).aspx#transitions_dom_events

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simple .toLowerCase() should do it then. That's what I did for https://github.com/mgcrea/angular-touch-nav

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding setting styles on the element, Firefox uses uppercase for it's Moz prefix. Webkit can use both upper and lowercase. Older versions of opera use the uppercase OTransition while new versions omit the O prefix. I'm testing further with the events now...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matsko Opera 12.1x, i.e. the oldest Presto Opera doesn't need a prefix, Firefox has long dropped it as well. I think only the WebKit prefix is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Webkit can be both so I think the code is fine. Maybe I should run a test through browser stack just to be sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like webkit has to be lowercase for this particular event as well as transition end.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even more reasons to just special-case WebKit here and get rid of the rest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moz was taken out in FF16. I doubt anyone is using that version since it's almost 10 versions back on the current version of FF.

@matsko
Copy link
Contributor Author

matsko commented Sep 5, 2013

This PR needs to work with this issue first: #3874


//but some still use vendor-prefixed styles
var vendorAnimationProp = $sniffer.vendorPrefix + 'Animation';
var vendorTransitionProp = $sniffer.vendorPrefix + 'Transition';
var vendorAnimationEvent = $sniffer.vendorPrefix.toLowerCase() + 'AnimationEnd';
var vendorTransitionEvent = $sniffer.vendorPrefix.toLowerCase() + 'TransitionEnd';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use transitionendEvent variable defined as follows:

var transitionendEvent = window.ontransitionend !== undefined ?
    'transitionend' :
    window.onwebkittransitionend !== undefined ? 'webkitTransitionEnd' : undefined;

similarly with animationend? All the detection would be in one place, it would eliminate further duplication.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matsko This is a good point. Can we simplify this in future PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhevery Sure, if that's easier for you. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhevery By "we" did you mean that sb has plans to do that or did you ask me to create a PR with a change? :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhevery nvm, I'm on it :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhevery @matsko Here you are: #3908

@mhevery
Copy link
Contributor

mhevery commented Sep 5, 2013

Seems like the tests fail on this one: http://ci.angularjs.org/view/Misko's/job/angular.js-misko/846/console

@mhevery mhevery merged commit 32ad292 into angular:master Sep 6, 2013
@gunn
Copy link

gunn commented Sep 6, 2013

@mhevery fixed ~40 of the errors with #3902

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

Successfully merging this pull request may close these issues.

ngAnimate causes flashes if new animations are fired too quickly [ngAnimate] timing issues with 1.2.0-rc1
4 participants