File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export default class Keyframes extends React.Component {
99 delay : PropTypes . number ,
1010 loop : PropTypes . oneOfType ( [
1111 React . PropTypes . string ,
12+ React . PropTypes . number ,
1213 React . PropTypes . bool
1314 ] ) ,
1415 onStart : PropTypes . func ,
@@ -18,14 +19,17 @@ export default class Keyframes extends React.Component {
1819 static defaultProps = {
1920 component : 'span' ,
2021 delay : 0 ,
21- lopp : false ,
22+ loop : 1 ,
2223 onStart : noop ,
2324 onEnd : noop
2425 } ;
2526
2627 constructor ( props ) {
2728 super ( props ) ;
28- this . state = { frameNum : this . props . delay ? - 1 : 0 } ;
29+ this . state = {
30+ frameNum : this . props . delay ? - 1 : 0 ,
31+ loopNum : 0
32+ } ;
2933 this . timer = null ;
3034 }
3135
@@ -70,9 +74,13 @@ export default class Keyframes extends React.Component {
7074 requestNextFrame ( ) {
7175 this . waitForDelay ( ( ) => {
7276 const frameNum = this . state . frameNum + 1 ;
77+ const loopNum = this . state . loopNum + 1 ;
7378 if ( this . props . children . length <= frameNum ) {
74- if ( this . props . loop === true || this . props . loop === 'infinite' ) {
75- this . setState ( { frameNum : 0 } ) ;
79+ if ( this . props . loop === true || this . props . loop == 'infinite' || loopNum < this . props . loop ) {
80+ this . setState ( {
81+ frameNum : 0 ,
82+ loopNum
83+ } ) ;
7684 } else {
7785 this . props . onEnd ( ) ;
7886 return ;
You can’t perform that action at this time.
0 commit comments