@@ -225,10 +225,14 @@ class QueueAnim extends React.Component {
225
225
226
226
enterBegin ( key , elements ) {
227
227
elements . forEach ( ( elem ) => {
228
- elem . className += ( ' ' + this . props . animatingClassName [ 0 ] ) ;
229
- const currentClassName = this . props . animatingClassName [ 1 ] ;
230
- const reg = new RegExp ( currentClassName , 'g' ) ;
231
- elem . className = elem . className . replace ( reg , '' ) ;
228
+ const animatingClassName = this . props . animatingClassName ;
229
+ if ( elem . className . indexOf ( this . props . animatingClassName [ 1 ] ) >= 0 ) {
230
+ const reg = new RegExp ( animatingClassName [ 1 ] , 'g' ) ;
231
+ elem . className = elem . className . replace ( reg , '' ) ;
232
+ }
233
+ if ( elem . className . indexOf ( ' ' + animatingClassName [ 0 ] ) === - 1 ) {
234
+ elem . className += ( ' ' + animatingClassName [ 0 ] ) ;
235
+ }
232
236
} ) ;
233
237
}
234
238
@@ -237,18 +241,22 @@ class QueueAnim extends React.Component {
237
241
this . keysAnimating . splice ( this . keysAnimating . indexOf ( key ) , 1 ) ;
238
242
}
239
243
elements . forEach ( ( elem ) => {
240
- const currentClassName = this . props . animatingClassName [ 0 ] ;
241
- const reg = new RegExp ( currentClassName , 'g' ) ;
242
- elem . className = elem . className . replace ( reg , '' ) . trim ( ) ;
244
+ if ( elem . className . indexOf ( this . props . animatingClassName [ 0 ] ) >= 0 ) {
245
+ elem . className = elem . className . replace ( this . props . animatingClassName [ 0 ] , '' ) . trim ( ) ;
246
+ }
243
247
} ) ;
244
248
}
245
249
246
250
leaveBegin ( elements ) {
247
251
elements . forEach ( ( elem ) => {
248
- elem . className += ( ' ' + this . props . animatingClassName [ 1 ] ) ;
249
- const currentClassName = this . props . animatingClassName [ 0 ] ;
250
- const reg = new RegExp ( currentClassName , 'g' ) ;
251
- elem . className = elem . className . replace ( reg , '' ) ;
252
+ const animatingClassName = this . props . animatingClassName ;
253
+ if ( elem . className . indexOf ( animatingClassName [ 0 ] ) >= 0 ) {
254
+ const reg = new RegExp ( animatingClassName [ 0 ] , 'g' ) ;
255
+ elem . className = elem . className . replace ( reg , '' ) ;
256
+ }
257
+ if ( elem . className . indexOf ( animatingClassName [ 1 ] ) === - 1 ) {
258
+ elem . className += ( ' ' + animatingClassName [ 1 ] ) ;
259
+ }
252
260
} ) ;
253
261
}
254
262
@@ -271,9 +279,9 @@ class QueueAnim extends React.Component {
271
279
} ) ;
272
280
}
273
281
elements . forEach ( ( elem ) => {
274
- const currentClassName = this . props . animatingClassName [ 1 ] ;
275
- const reg = new RegExp ( currentClassName , 'g' ) ;
276
- elem . className = elem . className . replace ( reg , '' ) . trim ( ) ;
282
+ if ( elem . className . indexOf ( this . props . animatingClassName [ 1 ] ) >= 0 ) {
283
+ elem . className = elem . className . replace ( this . props . animatingClassName [ 1 ] , '' ) . trim ( ) ;
284
+ }
277
285
} ) ;
278
286
}
279
287
0 commit comments