MCPcopy
hub / github.com/xiaolin/react-image-gallery / isFlickSwipe

Function isFlickSwipe

src/components/utils/swipe.ts:67–78  ·  view source on GitHub ↗
(
  velocity: number,
  flickThreshold: number,
  direction: SwipeDirection,
  slideVertically: boolean
)

Source from the content-addressed store, hash-verified

65 * Determines whether a swipe gesture qualifies as a "flick" (fast swipe).
66 */
67export function isFlickSwipe(
68 velocity: number,
69 flickThreshold: number,
70 direction: SwipeDirection,
71 slideVertically: boolean
72): boolean {
73 const isSwipeUpOrDown = direction === "Up" || direction === "Down";
74 const isSwipeLeftOrRight = direction === "Left" || direction === "Right";
75 const isLeftRightFlick = velocity > flickThreshold && !isSwipeUpOrDown;
76 const isTopDownFlick = velocity > flickThreshold && !isSwipeLeftOrRight;
77 return slideVertically ? isTopDownFlick : isLeftRightFlick;
78}
79
80/**
81 * Computes the target slide index after a swipe ends.

Callers 2

ImageGallery.tsxFile · 0.90
swipe.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected