JavaScript touch event - Limiting the amount of horizontal movement

Discussion in 'JavaScript' started by kayut, Apr 25, 2017.

  1. #1
    Hi,

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

    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?

    Thanks
     
    kayut, Apr 25, 2017 IP