Skip to content

Instantly share code, notes, and snippets.

View zipang's full-sized avatar
🏠
Working from home

Christophe Desguez zipang

🏠
Working from home
  • EIDOLON LABS
  • France
View GitHub Profile
@zipang
zipang / use-swipe.ts
Last active May 21, 2025 13:34
useSwipe (React Hook)
import { useEffect, useLayoutEffect, useState, type RefObject } from "react";
type Direction = "top" | "bottom" | "left" | "right";
type Vector = [number, number];
interface UseSwipeOptions {
/**
* Callback for swipe events
*/
onSwipe: (direction: Direction, vector: Vector) => void;