Swiperia
Web (swiperia-js)

Configuration

Thresholds that decide whether a gesture counts as a swipe.

Every detector accepts an optional SwipeConfig.

const swiper = new Swiper(element, [MouseSwiper, TouchSwiper], {
  threshold: 10,
  allowedTime: 300,
});
OptionTypeDefaultDescription
thresholdnumber10Minimum distance in pixels for the gesture to count.
allowedTimenumber300Maximum duration in milliseconds for the gesture to count.

How the constraint is applied

When the gesture finishes, the detector compares it against both values:

const passed = duration <= allowedTime && distance >= threshold;

Passing emits an end event; failing emits a cancel event. Both carry the same movement data, so cancel is still useful — it tells you the user tried.

distance is the straight-line distance between the start and end points, not the length of the path travelled. A long looping gesture that returns near its origin fails the threshold.

Raise threshold when an element also handles clicks, so small imprecise presses are not read as swipes. Raise allowedTime if you want slow, deliberate drags to count.

On this page