Looking for help with creating an automatic infinite slider that swipes left and right? Check out this code snippet!
If anyone can assist with achieving this, it would be greatly appreciated.
Link to the CodePen: http://codepen.io/Taron/pen/jyeIi
JavaScript Code Below:
window.addEventListener('load', onWndLoad, false);
function onWndLoad() {
var slider = document.querySelector('.slider');
var sliders = slider.children;
var initX = null;
var transX = 0;
var rotZ = 0;
var transY = 0;
var curSlide = null;
var Z_DIS = 50;
var Y_DIS = 10;
var TRANS_DUR = 0.4;
var images=document.querySelectorAll('img');
for(var i=0; i<images.length; i++) {
images[i].onmousemove = function(e) {
e.preventDefault();
}
images[i].ondragstart = function(e) {
return false;
}
}
function init() {
var z = 0, y = 0;
for (var i = sliders.length-1; i >= 0; i--) {
sliders[i].style.transform = 'translateZ(' + z + 'px) translateY(' + y + 'px)';
z -= Z_DIS;
y += Y_DIS;
}
attachEvents(sliders[sliders.length - 1]);
}
function attachEvents(elem) {
curSlide = elem;
curSlide.addEventListener('mousedown', slideMouseDown, false);
curSlide.addEventListener('touchstart', slideMouseDown, false);
}
// Additional JavaScript functions...
}
// Continue adding more JavaScript functions here...