Skip to content
Advertisement

Click to go next position in live animation

I created an animation that goes from right to left, and I am trying to add some jump on click of next box button.

How can I apply it using JavaScript ?

nextBox function should apply the jump from box1 to box2 and so on… ( for example )

JavaScript
JavaScript
JavaScript

codepen here

Advertisement

Answer

The following implementation should work since it does what you want.

Here we have another boxContainer div to apply transition to and let the animation remain on anim class wrapper div. Also we can have another div of class pseudoBox whose width we increase by 100px to fill out the empty spacing we encounter later and to keep the order of box divs constant, we keep on appending the first box class div at the end in a cyclic fashion. I have numbered the boxes for better understanding. So our original no of box divs remain constant.

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement