View Full Version : JavaScript touch event - controlling the amount of horizontal movement

04-25-2017, 03:31 PM

I'm just learning the JavaScript touch event. For this I created this example:

Example on Codepen (https://codepen.io/itsthomas/pen/BRQzBw?editors=0110)

In the above example, you can grab the element and move it to the right or left.

It works. However I want to limit the horizontal movement of the element (for example only 100px to the left and 100px to the right).

How can I do this?