Long Press / Long click /touch on Gear S/S2 web app

Long Press / Long click /touch on Gear S/S2 web app

BY 16 Nov 2015 Web Application Development

Hi,

I am trying to add a long press event for long presses on my buttons.

Currently I have the basic, “click” event by this command:

b.addEventListener(“click”, go);

I  realized that long press is not supported by default. So I decided to use hammer.js 

I included the hammer.js by following code on my index.html:

<script type=”text/javascript”  src=”js/hammer.js”></script>

<script src=”js/main.js”></script>

 

Then in the main.js I added the new event by:

var mc = new Hammer(b);

mc.on(“press”, go2);

 

b is defined by:

b = document.querySelector(“.b1);

 

But the go2  function is never triggered.

Even when I disable the go function by disabling “click” event, go2 is not triggered.

How can I add long click/press event to my app ?

examples from:

http://codepen.io/jtangelder/pen/lgELw

Thanks.

 

 

Written by