( currentIndex: number, swipeDirection: number, isSufficient: boolean, isFlick: boolean, isTransitioning: boolean, canSlideLeft: boolean, canSlideRight: boolean )
| 81 | * Computes the target slide index after a swipe ends. |
| 82 | */ |
| 83 | export function computeSlideTarget( |
| 84 | currentIndex: number, |
| 85 | swipeDirection: number, |
| 86 | isSufficient: boolean, |
| 87 | isFlick: boolean, |
| 88 | isTransitioning: boolean, |
| 89 | canSlideLeft: boolean, |
| 90 | canSlideRight: boolean |
| 91 | ): number { |
| 92 | let slideTo = currentIndex; |
| 93 | |
| 94 | if ((isSufficient || isFlick) && !isTransitioning) { |
| 95 | slideTo += swipeDirection; |
| 96 | } |
| 97 | |
| 98 | // Clamp: if we can't slide in the requested direction, stay put |
| 99 | if (swipeDirection === -1 && !canSlideLeft) { |
| 100 | slideTo = currentIndex; |
| 101 | } |
| 102 | if (swipeDirection === 1 && !canSlideRight) { |
| 103 | slideTo = currentIndex; |
| 104 | } |
| 105 | |
| 106 | return slideTo; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Computes the target displayIndex for the CSS transform. |
no outgoing calls
no test coverage detected