File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -163,9 +163,17 @@ export default class ImageGallery extends React.Component {
163163 } ,
164164 } ;
165165
166+ componentDidMount ( ) {
167+ if ( this . props . autoPlay ) {
168+ this . play ( ) ;
169+ }
170+ window . addEventListener ( 'keydown' , this . _handleKeyDown ) ;
171+ this . _onScreenChangeEvent ( ) ;
172+ }
173+
166174 componentDidUpdate ( prevProps , prevState ) {
167175 const itemsSizeChanged = prevProps . items . length !== this . props . items . length ;
168- const itemsChanged = prevProps . items !== this . props . items ;
176+ const itemsChanged = JSON . stringify ( prevProps . items ) !== JSON . stringify ( this . props . items ) ;
169177 const startIndexUpdated = prevProps . startIndex !== this . props . startIndex ;
170178 if ( itemsSizeChanged ) {
171179 this . _handleResize ( ) ;
@@ -188,14 +196,6 @@ export default class ImageGallery extends React.Component {
188196 }
189197 }
190198
191- componentDidMount ( ) {
192- if ( this . props . autoPlay ) {
193- this . play ( ) ;
194- }
195- window . addEventListener ( 'keydown' , this . _handleKeyDown ) ;
196- this . _onScreenChangeEvent ( ) ;
197- }
198-
199199 componentWillUnmount ( ) {
200200 window . removeEventListener ( 'keydown' , this . _handleKeyDown ) ;
201201
You can’t perform that action at this time.
0 commit comments