Accessors
All Module accessors are available in this class.
coords
Type: ISwipeCoords
Full snapshot: pointer fields plus movement-space fields (movement, prevMovement, scale).
const instance = new Swipe();
instance.coords.movement.x;
instance.coords.scale;
instance.coords.diff.x;
container
Type: HTMLElement | SVGElement
Coordinate reference element (props.container).
const instance = new Swipe();
instance.container;
movement
Type: ISwipeVec3
Total displacement in movement space (rubber + snap). Use for transforms when bounds / snap are enabled.
const instance = new Swipe({
bounds: () => ({ x: [0, 200] }),
onMove: ({ movement, scale }) => {
el.style.transform = `translate(${movement.x}px, ${movement.y}px) scale(${scale})`;
},
});
instance.movement.x;
scale
Type: number
Current scale modifier in movement space. Default is 1. Updated by setScale. Included in ISwipeCoords on callbacks.
const instance = new Swipe({
onMove: ({ movement, scale }) => {
el.style.transform = `translate(${movement.x}px, ${movement.y}px) scale(${scale})`;
},
});
instance.scale;
start
Type: ISwipeState
Pointer position at swipe start.
instance.start.x;
instance.start.time;
prev
Type: ISwipeState
Previous pointer position.
instance.prev.x;
current
Type: ISwipeState
Current pointer position.
instance.current.x;
instance.current.angle;
diff
Type: ISwipeState
Offset from swipe start to current pointer position (pointer space).
instance.diff.x;
instance.diff.angle;
step
Type: ISwipeState
Offset from previous to current pointer position.
instance.step.x;
accum
Type: ISwipeVec3
Absolute path length since swipe start (|step| per axis).
instance.accum.x;
instance.accum.angle;
hasInertia
Type: boolean
Whether release inertia (RAF) is running.
instance.hasInertia;
hasBounce
Type: boolean
Whether overflow bounce-back timeline is running.
instance.hasBounce;
isSwiping
Type: boolean
Whether a swipe gesture is in progress.
instance.isSwiping;