File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 11import React , { Component } from 'react' ;
22import PropTypes from 'prop-types' ;
33
4+ const requestAnimationFrame = window . requestAnimationFrame || window . mozRequestAnimationFrame ||
5+ window . webkitRequestAnimationFrame || window . msRequestAnimationFrame ;
6+ const cancelAnimationFrame = window . cancelAnimationFrame || window . mozCancelAnimationFrame ;
7+
48export default class TextTruncate extends Component {
59 static propTypes = {
610 containerClassName : PropTypes . string ,
@@ -36,10 +40,16 @@ export default class TextTruncate extends Component {
3640
3741 componentWillUnmount ( ) {
3842 window . removeEventListener ( 'resize' , this . onResize ) ;
43+ if ( this . rafId ) {
44+ cancelAnimationFrame ( this . rafId ) ;
45+ }
3946 }
4047
4148 onResize = ( ) => {
42- window . requestAnimationFrame ( this . update . bind ( this ) )
49+ if ( this . rafId ) {
50+ cancelAnimationFrame ( this . rafId ) ;
51+ }
52+ this . rafId = requestAnimationFrame ( this . update . bind ( this ) )
4353 } ;
4454
4555 update = ( ) => {
You can’t perform that action at this time.
0 commit comments