angularjs - What is the best way ( performance wise ) to animate numbers? -


in angular.js app i'm using directive:

https://github.com/sparkalow/angular-count-to 

which works great on web.

when compile phonegap, it's really slow.

but other way have animate number 0 200 (for example), in 2 secods, without hurting performance of app?

the directive uses $timeout, suggested way settimeout functionality in angular. it's doing 1 of following reasons, though there others too:

  1. easy inject mock testing
  2. assumes each step should allow other components update
  3. it's "angular way"

i don't believe #2 big concern since doesn't expose value or update on scope anyway, , standard html textcontent manipulation.

regardless, point $timeout settimeout $digest (allowing angular update other components). digest cycles slow part, , every angular developer should read on them they're central angular's design (hint: go read on these now). such, taking original library, replacing $timeout settimeout call (and, optionally, manual digest trigger when finishes, in if (step >= steps) block) should speed up.

be careful these sorts of changes, though - $timeout typically correct way go.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -