@@ -127,7 +127,10 @@ export function DSlides<ID extends DId, T extends DSlideItem<ID>>(props: DSlides
127
127
dataRef . current . clearTid = async . setTimeout (
128
128
( ) => {
129
129
dataRef . current . clearTid = undefined ;
130
- changeActiveId ( dList [ ( activeIndex + 1 ) % dList . length ] . id ) ;
130
+ const id = nth ( dList , ( activeIndex + 1 ) % dList . length ) ?. id ;
131
+ if ( ! isUndefined ( id ) ) {
132
+ changeActiveId ( id ) ;
133
+ }
131
134
} ,
132
135
autoplay . delay ,
133
136
( ) => {
@@ -219,10 +222,16 @@ export function DSlides<ID extends DId, T extends DSlideItem<ID>>(props: DSlides
219
222
}
220
223
if ( newIndex === activeIndex ) {
221
224
if ( performance . now ( ) - dataRef . current . startDragTime < 300 && Math . abs ( dragDistance ) > 30 ) {
222
- changeActiveId ( dList [ Math . max ( newIndex - 1 , 0 ) ] . id ) ;
225
+ const id = nth ( dList , Math . max ( newIndex - 1 , 0 ) ) ?. id ;
226
+ if ( ! isUndefined ( id ) ) {
227
+ changeActiveId ( id ) ;
228
+ }
223
229
}
224
230
} else {
225
- changeActiveId ( dList [ newIndex ] . id ) ;
231
+ const id = nth ( dList , newIndex ) ?. id ;
232
+ if ( ! isUndefined ( id ) ) {
233
+ changeActiveId ( id ) ;
234
+ }
226
235
}
227
236
} else {
228
237
let newIndex = activeIndex ;
@@ -237,10 +246,16 @@ export function DSlides<ID extends DId, T extends DSlideItem<ID>>(props: DSlides
237
246
}
238
247
if ( newIndex === activeIndex ) {
239
248
if ( performance . now ( ) - dataRef . current . startDragTime < 300 && Math . abs ( dragDistance ) > 30 ) {
240
- changeActiveId ( dList [ Math . min ( newIndex + 1 , dList . length - 1 ) ] . id ) ;
249
+ const id = nth ( dList , Math . min ( newIndex + 1 , dList . length - 1 ) ) ?. id ;
250
+ if ( ! isUndefined ( id ) ) {
251
+ changeActiveId ( id ) ;
252
+ }
241
253
}
242
254
} else {
243
- changeActiveId ( dList [ newIndex ] . id ) ;
255
+ const id = nth ( dList , newIndex ) ?. id ;
256
+ if ( ! isUndefined ( id ) ) {
257
+ changeActiveId ( id ) ;
258
+ }
244
259
}
245
260
}
246
261
}
@@ -363,7 +378,10 @@ export function DSlides<ID extends DId, T extends DSlideItem<ID>>(props: DSlides
363
378
tabIndex = { - 1 }
364
379
disabled = { activeIndex === 0 }
365
380
onClick = { ( ) => {
366
- changeActiveId ( dList [ activeIndex - 1 ] . id ) ;
381
+ const id = nth ( dList , activeIndex - 1 ) ?. id ;
382
+ if ( ! isUndefined ( id ) ) {
383
+ changeActiveId ( id ) ;
384
+ }
367
385
} }
368
386
>
369
387
< LeftOutlined />
@@ -375,7 +393,10 @@ export function DSlides<ID extends DId, T extends DSlideItem<ID>>(props: DSlides
375
393
tabIndex = { - 1 }
376
394
disabled = { activeIndex === dList . length - 1 }
377
395
onClick = { ( ) => {
378
- changeActiveId ( dList [ activeIndex + 1 ] . id ) ;
396
+ const id = nth ( dList , activeIndex + 1 ) ?. id ;
397
+ if ( ! isUndefined ( id ) ) {
398
+ changeActiveId ( id ) ;
399
+ }
379
400
} }
380
401
>
381
402
< RightOutlined />
0 commit comments