var platforms = document.querySelector('.platforms .slide-track') var rollingAnimation = platforms.animate([ { transform: 'translateX(0)' }, { transform: `translateX(${-200 * 13}px)` } ], { iterations: Infinity, duration: 30 * 1000 }); function rollCarousel() { rollingAnimation.play() } function pauseCarousel() { rollingAnimation.pause(); } platforms.addEventListener('mouseover', pauseCarousel) platforms.addEventListener('mouseout', rollCarousel) $('a.taphover').on("touchstart", function (e) { "use strict"; //satisfy the code inspectors var link = $(this); //preselect the link if (link.hasClass('hover')) { return true; } else { link.addClass("hover"); $('a.taphover').not(this).removeClass("hover"); e.preventDefault(); return false; //extra, and to make sure the function has consistent return points } });