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

[don't merge]: fix($animateCss): respect transition styles already on the element #13488

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Narretz
Copy link
Contributor

@Narretz Narretz commented Dec 10, 2015

Previously, $animateCss wouldn't use transition styles that were on the element
before the animation process started. Precisely, transition property, timing-function
and delay were overwritten in the process.

Closes #12656
Closes #13333

flags.hasTransitionAll = flags.hasTransitions && timings.transitionProperty == 'all';
flags.applyTransitionDuration = hasToStyles && (
(flags.hasTransitions && !flags.hasTransitionAll)
flags.applyTransitionDuration = options.duration > 0 || hasToStyles && (flags.hasTransitions
|| (flags.hasAnimations && !flags.hasTransitions));
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if this expressionis correct, but if it is, it can be simplified to:

options.duration > 0 || hasToStyles && (flags.hasTransitions || flags.hasAnimations)

Copy link
Member

Choose a reason for hiding this comment

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

Same as above: What if options.duration === 0 ?
I think we want to support that as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the duration is 0, no animation is performed, and no styles are added at all .. but that is only tested for styles that are added to the element, not those that are already on the element

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that it's not entirely clear what $animateCss should do with styles that are already on the element when it is called. Should it ignore those or incorporate them? With all this addClass and to properties, it becomes really complex.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but what if the element has transition styles with transition-duration > 0 whereas options.duration === 0.
E.g. the user wants to have a 0-duration animation (i.e. skip the animation for whatever reason), on an element that would normally animate (because it has transition-duration > 0).

Or is it so edgy a case, that we don't need to support it ? 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The value in the options always takes precedence. I've tested it, whatever is set in the styles, if you options.duration = 0, no animation is run.

Copy link
Member

Choose a reason for hiding this comment

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

Cool then :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see the problem. You are right, if an element has transitions defined before animateCss is called on it, and the user set options.duration: 0, then $animateCss will not animate, but that means the transition styles on the element will take over anyway. So it's actually not possible to overwrite an exisiting transition with duration: 0. @matsko do you think that should be possible?.

@matsko
Copy link
Contributor

matsko commented Dec 17, 2015

Mobile Safari is still broken on this one.

Previously, $animateCss wouldn't use transition styles that were on the element
before the animation process started. Precisely, transition property, timing-function
and delay were overwritten in the process.

Closes angular#12656
Closes angular#13333
- since transition / animation styles are now set on the element even
if the transition property is all, the condition for setting the
transitionDuration can be simplified
- explain why we test for cubic bezier and ease
- rename a parameter
@Narretz Narretz force-pushed the fix-animateCss-12656-rebased branch 2 times, most recently from f7e3533 to 505c11a Compare December 17, 2015 19:22
@petebacondarwin
Copy link
Contributor

Moving to 1.5.x as it not going to make it into 1.5.0

@petebacondarwin petebacondarwin modified the milestones: 1.5.x - migration-facilitation, 1.5.0-rc.2 Jan 27, 2016
@Narretz Narretz modified the milestones: 1.5.x, 1.7.x Apr 12, 2018
@petebacondarwin petebacondarwin self-assigned this May 14, 2018
@petebacondarwin petebacondarwin removed their assignment May 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ngAnimate assumes transition is linear instead of using the value in CSS
5 participants