Any suggestions on how best to detect the duration of the touch of an object/button? I want to initiate some action if a button has received a long press (say > 1 sec or > 3 sec). This will be via touchscreen, not mouse. Is this even easily possible?
// Get a reference to an element
var square = hypeDocument.getElementById('square');
// Create a manager to manager the element
var manager = new Hammer.Manager(square);
// Create a recognizer
var Press = new Hammer.Press({
time: 1000
});
// Add the recognizer to the manager
manager.add(Press);
// Subscribe to desired event
manager.on('press', function(e) {
hypeDocument.startTimelineNamed('1secpress', hypeDocument.kDirectionForward, false)
});
It plays a timeline after a press has been detected for 1 second. Hammer.js is great if you want to do other touch-related things down the line: https://hammerjs.github.io/