Skip to content

Latest commit

 

History

History
47 lines (32 loc) · 1.51 KB

advanced.md

File metadata and controls

47 lines (32 loc) · 1.51 KB

Advanced use

Block default events

The parameter "preventDefault" is a function that can decide whether to "prevent the default event" by its return value of "true/false".

For example implementation: The "default event" that prevents multi-triggered events, such as "pinch/rotate".

const at = new AnyTouch(el, {
     preventDefault(e) {
         return 1 == e.touches.length;
     },
});

The parameter "e" is the native event object, the mobile terminal is TouchEvent, and the PC terminal is MouseEvent.

🚀 back to directory

"at:xxx" event

Broad event hooks.

Name Description
at:start start touch/touch increase trigger
at:move Contact move trigger
at:end Contact leave trigger
at:after After any event is triggered, it will be triggered

The event object of "at:after" is different from other events, it has one more name field, this name indicates which event caused "at:after".

at.on('at:after', (e) => {
     // ⭐tap/pan/swipe/press/pinch/rotate/at:start/at:move/at:end
     console.log(e.name);
});

🚀 back to directory