izupet / angular2-counto

Angular 2 package for nice count animations
MIT License
40 stars 13 forks source link

multiple elements in the same page malfunctioning #8

Closed ebicoglu closed 7 years ago

ebicoglu commented 7 years ago

when you put 2 counto elements on the same html then both counts up to the same value. i guess because of a static variable

izupet commented 7 years ago

You should use multiple counto directives like this (each countoChange event value should be set to different variable):

<div counto [step]="30" [countTo]="10" [countFrom]="0" [duration]="3" (countoChange)="a = $event">{{a}}</div><div counto [step]="30" [countTo]="20" [countFrom]="0" [duration]="10" (countoChange)="b = $event">{{b}}</div>

ebicoglu commented 7 years ago

Thanks. working now :)