( slideTo: number, totalSlides: number, totalDisplaySlides: number, infinite: boolean )
| 111 | * Mirrors the logic in slideToIndexCore from useGalleryNavigation. |
| 112 | */ |
| 113 | export function computeTargetDisplayIndex( |
| 114 | slideTo: number, |
| 115 | totalSlides: number, |
| 116 | totalDisplaySlides: number, |
| 117 | infinite: boolean |
| 118 | ): number { |
| 119 | const slideCount = totalSlides - 1; |
| 120 | |
| 121 | if (slideTo < 0) { |
| 122 | // Wrapping start (going past first slide) |
| 123 | return 0; |
| 124 | } |
| 125 | if (slideTo > slideCount) { |
| 126 | // Wrapping end (going past last slide) |
| 127 | return infinite && totalSlides > 1 ? totalDisplaySlides - 1 : slideCount; |
| 128 | } |
| 129 | // Normal navigation |
| 130 | return infinite && totalSlides > 1 ? slideTo + 1 : slideTo; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Computes the CSS transition duration based on the swipe velocity, |
no outgoing calls
no test coverage detected