V
V
Vladimir13802018-11-07 05:41:51
JavaScript
Vladimir1380, 2018-11-07 05:41:51

How to move elements in javascript one position right and left on touchmove event?

There is an ordinary div, in which identical elements with different numerical indices are absolutely positioned around the perimeter with classes like pos-0, pos1, etc.. Canvas is not used.
It is necessary, when touchmove events are fixed, to determine the direction to the right or left and move all elements by one position. That is, 1 to position 2 (right), 2 to 3, or 1 to position 10 (left), etc. one after the other?
Perhaps by dynamically changing the classes that set the absolute positioning of each individual element. What is the best way to do this smoothly in js/jquery?
The elements are arranged like this;
50c518c7e0.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
axeax, 2018-11-07
@axeax

If you should end up with something like a spinner, then:
1) when touchstart, remember x
2) when touchmove, if moveX> x means to the right, and vice versa
3) in accordance with the direction, we set new classes or positions for the elements, depends on what you need to get in the end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question