DDI

<No title set>

This page was updated in v2.11.0

Swipe Gesture System

The swipe gesture system provides touch and pointer-based swipe tracking with typed events.

Features

Basic Usage

---
import { SwipeObserver, onSwipe } from "@dynamic-type/ddi/server";
---

<SwipeObserver />

<div data-ddi-swipe="x">Swipe me horizontally</div>

<script>
    import { onSwipe } from "@dynamic-type/ddi/client";

    onSwipe({
        move: (e) => {
            e.detail.target.style.transform = `translateX(${e.detail.deltaX}px)`;
        },
        end: (e) => {
            if (Math.abs(e.detail.velocityX) > 0.5) {
                console.log("Fling detected!");
            }
        },
    });
</script>

Debug Panel

Live display of swipe event data. Touch or drag in the panel below to see real-time values.

Position:(-, -)
Start:(-, -)
Delta:(-, -)
Velocity:(-, -)
Direction:-
Locked Axis:-
State:idle