ewizardjs-touch v1.4.5
Touch
This module is a set of additional events and properties to handle user interaction. Use this module in your components to work with UI events universally.
Installation
co module install --save cobalt/touchUsage
var touch = require('touch');API
events(object) - is an object containing a set of read-only keys. The values of these properties are the names of user events depending on the device the script is running on.Properties:
* `start` - mousedown | touchstart * `move` - mousemove | touchmove * `end` - mouseup | touchendisTouch(boolean) -trueif the script is running on mobile device, otherwise -false.getOriginalEvent(event)- returns event object bound to a specific finger (event.changedTouches[0]), in case the script is running on mobile device or event object itself.Example:
document.addEventListener(touch.events.start, function(event){ event = touch.getOriginalEvent(event); console.log(event.pageX); });events.startproperty is used in this example to handlemousedownandtouchstartevents simultaneously, depending on the platform.getOriginalEventfunction is called in the event handler to work with the actual event object.init(root)- emulates events dispatching for root elements and all of it's children.root- root element for events dispatching.
Events
swipeleft- is triggered when the user presses down and swipes over an element in the left directionswiperight- is triggered when the user presses down and swipes over an element in the right directionswipeup- is triggered when the user presses down and swipes over an element upwardswipedown- is triggered when the user presses down and swipes over an element downwardtap- is triggered when the user touches the screen (it is fired beforeclick)hold- is triggered when the user touches the screen and holds it for 500ms
8 years ago