@@ -254,18 +254,29 @@ export const Carousel: FunctionComponent<CarouselProps> = (userProps: CarouselPr
254
254
} ;
255
255
256
256
const onLeftArrowClick = ( ) => {
257
- slide ( SlideDirection . Left )
257
+ slide ( SlideDirection . Left ) ;
258
258
if ( props . onLeftArrowClick ) {
259
259
props . onLeftArrowClick ( ) ;
260
260
}
261
- }
261
+ } ;
262
262
263
263
const onRightArrowClick = ( ) => {
264
- slide ( SlideDirection . Right )
264
+ slide ( SlideDirection . Right ) ;
265
265
if ( props . onRightArrowClick ) {
266
266
props . onRightArrowClick ( ) ;
267
267
}
268
- }
268
+ } ;
269
+ const showLeftArrow =
270
+ props . arrowLogicOnEndOfPage === 'disable' ||
271
+ ( props . arrowLogicOnEndOfPage === 'hide' && showArrow . left ) ;
272
+ const showRightArrow =
273
+ props . arrowLogicOnEndOfPage === 'disable' ||
274
+ ( props . arrowLogicOnEndOfPage === 'hide' && showArrow . right ) ;
275
+
276
+ const leftArrowClassnames =
277
+ props . arrowLogicOnEndOfPage === 'disable' && ! showArrow . left ? 'disabled' : '' ;
278
+ const rightArrowClassnames =
279
+ props . arrowLogicOnEndOfPage === 'disable' && ! showArrow . right ? 'disabled' : '' ;
269
280
270
281
return (
271
282
< div
@@ -275,8 +286,8 @@ export const Carousel: FunctionComponent<CarouselProps> = (userProps: CarouselPr
275
286
{ ...( props . useArrowKeys ? { onKeyDown : handleOnKeyDown } : { } ) }
276
287
className = { `${ styles . carouselBase } ${ props . className } ` }
277
288
>
278
- { showArrow . left && (
279
- < div onClick = { onLeftArrowClick } >
289
+ { ! ! showLeftArrow && (
290
+ < div className = { leftArrowClassnames } onClick = { onLeftArrowClick } >
280
291
{ props . leftArrow ?? < Arrow direction = "left" /> }
281
292
</ div >
282
293
) }
@@ -289,8 +300,12 @@ export const Carousel: FunctionComponent<CarouselProps> = (userProps: CarouselPr
289
300
dragCallback = { dragCallback }
290
301
widthCallBack = { widthCallBack }
291
302
/>
292
- { showArrow . right && (
293
- < div onClick = { onRightArrowClick } ref = { slideButtonRef } >
303
+ { ! ! showRightArrow && (
304
+ < div
305
+ className = { rightArrowClassnames }
306
+ onClick = { onRightArrowClick }
307
+ ref = { slideButtonRef }
308
+ >
294
309
{ props . rightArrow ?? < Arrow direction = "right" /> }
295
310
</ div >
296
311
) }
@@ -324,6 +339,7 @@ export interface CarouselProps {
324
339
pageCount ?: number ;
325
340
leftArrow ?: ReactElement | null ;
326
341
rightArrow ?: ReactElement | null ;
342
+ arrowLogicOnEndOfPage ?: 'hide' | 'disable' ;
327
343
autoSwipe ?: number | null ;
328
344
navigation ?: null | ( ( selected : boolean ) => ReactElement ) ;
329
345
triggerClickOn ?: number ;
0 commit comments