@@ -23,7 +23,7 @@ class ReactRotatingText extends React.Component {
23
23
// save the timeouts so we can stop on unmount
24
24
const timeout = setTimeout ( loopingFunc , pause ) ;
25
25
this . timeouts . push ( timeout ) ;
26
-
26
+
27
27
// prevent memory leak
28
28
const maxTimeouts = 100 ;
29
29
if ( this . timeouts . length > maxTimeouts ) {
@@ -36,10 +36,10 @@ class ReactRotatingText extends React.Component {
36
36
const { output } = this . state ;
37
37
const { typingInterval } = this . props ;
38
38
const loopingFunc = this . _type . bind ( this , text , callback ) ;
39
-
39
+
40
40
// set the string one character longer
41
41
this . setState ( { output : text . substr ( 0 , output . length + 1 ) } ) ;
42
-
42
+
43
43
// if we're still not done, recursively loop again
44
44
if ( output . length < text . length ) {
45
45
this . _loop ( loopingFunc , typingInterval ) ;
@@ -52,10 +52,10 @@ class ReactRotatingText extends React.Component {
52
52
const { output } = this . state ;
53
53
const { deletingInterval } = this . props ;
54
54
const loopingFunc = this . _erase . bind ( this , callback ) ;
55
-
55
+
56
56
// set the string one character shorter
57
57
this . setState ( { output : output . substr ( 0 , output . length - 1 ) } ) ;
58
-
58
+
59
59
// if we're still not done, recursively loop again
60
60
if ( output . length !== 0 ) {
61
61
this . _loop ( loopingFunc , deletingInterval ) ;
@@ -77,16 +77,26 @@ class ReactRotatingText extends React.Component {
77
77
} ) ;
78
78
this . _loop ( loopingFunc , emptyPause ) ;
79
79
} ;
80
-
80
+
81
81
type . bind ( this ) ( items [ index ] , ( ) => {
82
82
this . _loop ( erase . bind ( this , nextWord ) , pause ) ;
83
83
} ) ;
84
84
} ;
85
85
86
86
render ( ) {
87
- const { color, cursor, ...other } = this . props ;
87
+ const {
88
+ color,
89
+ cursor,
90
+ deletingInterval,
91
+ emptyPause,
92
+ items,
93
+ pause,
94
+ typingInterval,
95
+ ...other
96
+ } = this . props ;
97
+
88
98
return (
89
- < span style = { { color : color } } { ...other } >
99
+ < span style = { { color } } { ...other } >
90
100
{ this . state . output }
91
101
{ cursor ? < span className = "react-rotating-text-cursor" > |</ span > : null }
92
102
</ span >
@@ -114,4 +124,4 @@ ReactRotatingText.defaultProps = {
114
124
typingInterval : 50 ,
115
125
} ;
116
126
117
- export default ReactRotatingText ;
127
+ export default ReactRotatingText ;
0 commit comments