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

perf(ngAnimate): cache repeated calls to addClass/removeClass#14166

Closed
wants to merge 1 commit into from

Conversation

matsko
Copy link
Contributor

Applies to 1.4.x and 1.5.x and master

Closes#14165
Closes#14166

@matskomatskoforce-pushed the fix_ng_animate_caching branch from e58c06b to 4745a0dCompareMarch 3, 2016 01:20
matsko added a commit to matsko/angular.js that referenced this pull request Mar 3, 2016
@matsko
Copy link
ContributorAuthor

Don't merge this yet. There's a cache issue.

@matskomatskoforce-pushed the fix_ng_animate_caching branch from 4745a0d to 0f15476CompareMarch 3, 2016 05:32
matsko added a commit to matsko/angular.js that referenced this pull request Mar 3, 2016
@matsko
Copy link
ContributorAuthor

OK now it's fixed.

@matskomatskoforce-pushed the fix_ng_animate_caching branch from 0f15476 to 1d766cfCompareMarch 3, 2016 05:42
@Narretz
Copy link
Contributor

Wow that's a ton of changes. I'll try to review today. However could you update the commit message with an explanation of the issue and the fix?

from: { background: 'red' },
to: { background: 'blue', 'font-size': '50px' }
from: { height: '100px' },
to: { height: '200px', 'font-size': '50px' }
Copy link
Contributor

Choose a reason for hiding this comment

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

@matsko why change these styles? It seems arbitrary.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

When the element is attached to a parent element then the colors are actually applied and getComputedStyle (which is what element.css in jQuery uses) actually figures out what the color is. Beforehand it was just using the inline style. Since we now deal with actually getting the RGB value for the color it was easier just to use a more stable value like a height measurement value.

@Narretz
Copy link
Contributor

Oh and @matsko can you add a demo that shows the speed up that this introduces?

@Narretz
Copy link
Contributor

Here's a plnkr to test the performance: http://plnkr.co/edit/bnaaaHbWkyQULeoOOg2X?p=preview

There's a simple ngRepeat that an ngClass on it. In my tests, ng animate with this test is about 30% faster.

However, if you include the <input> in the ngIf, the performance becomes pretty atrocious with both versions. There seems to be another problem there.

Regarding animating nth-child(x) elements in a repeater, that doesn't seem to work anyway: http://plnkr.co/edit/klCK5E22YPJ9Zfbz2meF?p=preview

@NarretzNarretz modified the milestones: 1.5.x, 1.6.xMar 8, 2017
@NarretzNarretz modified the milestones: 1.6.x, 1.7.xApr 12, 2018
@NarretzNarretz self-assigned this May 3, 2018
Narretz pushed a commit to Narretz/angular.js that referenced this pull request May 18, 2018
…imation has no duration Background: ngAnimate writes helper classes to DOM elements to see if animations are defined on them. If many elements have the same definition, we can cache the definition and skip the application of the helper classes altogether. This helps particularly with large ngRepeat collections. Closesangular#14165Closesangular#14166
Narretz pushed a commit to Narretz/angular.js that referenced this pull request Jun 25, 2018
…imation has no duration Background: ngAnimate writes helper classes to DOM elements to see if animations are defined on them. If many elements have the same definition, we can cache the definition and skip the application of the helper classes altogether. This helps particularly with large ngRepeat collections. Closesangular#14165Closesangular#14166
Narretz pushed a commit to Narretz/angular.js that referenced this pull request Jul 3, 2018
…imation has no duration Background: ngAnimate writes helper classes to DOM elements to see if animations are defined on them. If many elements have the same definition, we can cache the definition and skip the application of the helper classes altogether. This helps particularly with large ngRepeat collections. Closesangular#14165Closesangular#14166
Narretz pushed a commit to Narretz/angular.js that referenced this pull request Jul 4, 2018
…imation has no duration Background: ngAnimate writes helper classes to DOM elements to see if animations are defined on them. If many elements have the same definition, we can cache the definition and skip the application of the helper classes altogether. This helps particularly with large ngRepeat collections. Closesangular#14165Closesangular#14166
Narretz pushed a commit that referenced this pull request Jul 5, 2018
…imation has no duration Background: ngAnimate writes helper classes to DOM elements to see if animations are defined on them. If many elements have the same definition, and the same parent, we can cache the definition and skip the application of the helper classes altogether. This helps particularly with large ngRepeat collections. Closes#14165Closes#14166Closes#16613
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.
close