Standard Gestures
ZingTouch provides six standard gestures that are completely customizable.
Note: These demos are best viewed on a touch capable device.
ZingTouch provides six standard gestures that are completely customizable.
Note: These demos are best viewed on a touch capable device.
A tap event is a quick start and end of an input. Tap gestures can be configured with the amount of time inbetween a start and end, and the number of inputs it requires.
See the Pen ZingTouch | Tap Demo by ZingChart (@zingchart) on CodePen.
See the Pen ZingTouch | Rotate by ZingChart (@zingchart) on CodePen.
A Rotate is detected when the user has two inputs moving about a circle on the edges of a diameter.
A pinch is detected when the user has two inputs on the screen and moves one or both closer towards the other input, while expand is detected when the two inputs move further away from each other.
See the Pen ZingTouch | Pinch&Expand by ZingChart (@zingchart) on CodePen.
A pan is detected when the user touches the screen and moves about the area.
A swipe is detected when the user touches the screen and moves in a relatively increasing velocity, leaving the screen at some point before it drops below a certain velocity.
See the Pen ZingTouch | Bubble Swipe by ZingChart (@zingchart) on CodePen.
Adding ZingTouch to your website or application is extremely simple.
ZingTouch can be included either of two different ways :
import ZingTouch from 'zingtouch';
<script src='./path/to/zingtouch.min.js'></script>
Regions in ZingTouch are areas where all input events including mouse, touch, and pointer events are listened to. They hold any number of gestures you create and attach to elements.
Suppose we wanted to listen to some div with an id 'container' for all touch events.
var containerElement = document.getElementById('container'); var activeRegion = ZingTouch.Region(containerElement);
The region is now created and listening to every browser event inside of it.
Let's bind the Pan gesture to #object.
var childElement = document.getElementById('object'); activeRegion.bind(childElement, 'pan', function(event){ //Perform Operations });
Now the Pan gesture is bound to the 'object' element! Event tracking can start from the bound element, and end anywhere inside the region (including outside the bound element).
Panning - Start anywhere in the child area, and move about the child or into the parent area.
See the Pen ZingTouch | Region Demo by ZingChart (@zingchart) on CodePen.
ZingTouch isn't just about gestures. You can create new gestures and hook into ZingTouch's simplistic life cycle. Each gesture consists of start, move, and end events. Read More
Jump to our documentation on our README to learn how to use ZingTouch. ZingTouch is fully documented using JSDOC syntax and generated using ESDocs.
Fork us, Share us, Fix bugs with us. Any contribution is greatly appreciated.
ZingTouch was created as a by-product for enabling ZingChart to work better on mobile devices by adding a layer of gestures for interactivity. We needed gestures to make the user experience charts more seemless between mobile-centric interactions such as zooming and panning to explore data in a chart. The ZingChart-Mobile plugin was created in order to improve these features and enable ZingChart end-users to explore data differently on a mobile device. A live example is included in the gestures section of this page.