Hi so I'm trying to simulate arrows in a slider, where I move the elements to the left and right.
So far I have the items moving to the right but only once.
https://i.gyazo.com/34a0ef4a5064c2942aca7c717a775e8b.mp4
Here is my code so far
<script>
(function(){
const arrowLeft = document.querySelector('#video-tags-left');
const arrowRight = document.querySelector('#video-tags-right');
const tags = document.querySelector('.video-tags');
const now = "740";
arrowRight.addEventListener("click", function() {
$(tags).css({
"transform": "translate3d(" + -now + "px, 0px, 0px)",
"transform-style": "preserve-3d"
});
});
arrowLeft.addEventListener("click", function() {
$(tags).css({
"transform": "translate3d("+ +now+", 0px, 0px)",
"transform-style": "preserve-3d"
});
});
}());
</script>
So I'm trying to add and remove now which is 740 on click, so add 740 every time I click right and remove when I click left until it resets to 0px.
So I click right once 740 again 1460 etc and the reverse when the user clicks the left arrow.
Every time you click on one of the arrows you should increment/decrement the value of
now:Take into account that you will also have to check the limits of your slider so that you can not move the slider to sections where there is no content.