File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -802,28 +802,33 @@ class PlayModel extends BoundedIntModel {
802
802
this . set ( 'value' , this . get ( 'min' ) ) ;
803
803
this . schedule_next ( ) ;
804
804
} else {
805
- this . set ( 'playing' , false ) ;
805
+ this . pause ( ) ;
806
806
}
807
807
}
808
808
this . save_changes ( ) ;
809
809
}
810
810
811
811
schedule_next ( ) {
812
- window . setTimeout ( this . loop . bind ( this ) , this . get ( 'interval' ) ) ;
812
+ this . _timerId = window . setTimeout ( this . loop . bind ( this ) , this . get ( 'interval' ) ) ;
813
813
}
814
814
815
815
stop ( ) {
816
- this . set ( 'playing' , false ) ;
816
+ this . pause ( ) ;
817
817
this . set ( 'value' , this . get ( 'min' ) ) ;
818
818
this . save_changes ( ) ;
819
819
}
820
820
821
821
pause ( ) {
822
+ window . clearTimeout ( this . _timerId ) ;
823
+ this . _timerId = null ;
822
824
this . set ( 'playing' , false ) ;
823
825
this . save_changes ( ) ;
824
826
}
825
827
826
828
animate ( ) {
829
+ if ( this . _timerId !== null ) {
830
+ return ;
831
+ }
827
832
if ( this . get ( 'value' ) === this . get ( 'max' ) ) {
828
833
// if the value is at the end, reset it first, and then schedule the next
829
834
this . set ( 'value' , this . get ( 'min' ) ) ;
@@ -847,6 +852,8 @@ class PlayModel extends BoundedIntModel {
847
852
this . set ( '_repeat' , ! this . get ( '_repeat' ) ) ;
848
853
this . save_changes ( ) ;
849
854
}
855
+
856
+ private _timerId : number | null = null ;
850
857
}
851
858
852
859
export
You can’t perform that action at this time.
0 commit comments