JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container-fluid sliderContainer">
<div class="sliderControls">
<a href="#"><div class="leftControl"><img src="img/arrowLeft.png"></div></a>
<a href="#"><div class="rightControl"><img src="img/arrowRight.png"></div></a>
</div>
<section class="homeLeft leftSideHome leftSide">
<img src="img/vlargeblue.png" alt="v" class="vlargeimg2">
<div class="imageWrap">
<div class="imageWrap2">
<div class="homeimage1"></div>
<div class="homeimage2"></div>
</div>
</div>
</section>
<section class="homeRight rightSideHome rightSide">
<div class="imageWrap">
<div class="imageWrap2">
<div class="homeimage5"></div>
<div class="homeimage4"></div>
</div>
</div>
</section>
</div>
JavaScript
ar isiPad = navigator.userAgent.match(/iPad/i);
if ( !isiPad ) {
(function($,sr){
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
var obj = this, args = arguments;
function delayed () {
if (!execAsap)
func.apply(obj, args);
timeout = null;
};
if (timeout)
clearTimeout(timeout);
else if (execAsap)
func.apply(obj, args);
timeout = setTimeout(delayed, threshold || 100);
};
}
// smartresize
jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };
})(jQuery,'smartresize');
// setup initial variable containers use "var" to designate a new variable at highest scope then reset them as needed later.
var currImage = 0; // set our start number. Increment to figure out what the current image is
var totalImages = $(".leftSide .imageWrap2 div").length; // how many image sections are there
var imgHeight = $(window).height(); // get window size onLoad
var rightInitialY = (totalImages -1) * imgHeight * -1;
//get the start translateX set in CSS.
// We could do this with a transform matrix but the math is easier to follow.
// set our base postions so we can do some math
var leftY = 0;
var rightY = rightInitialY;
var myInterval; // build the timer container
// function to rotate images
rotateImages = function() {
if (currImage < totalImages -1) { // go to next image unless we're at the end of the list
var nextImg = currImage + 1; // increment image number
var targLY= leftY - (imgHeight); //move left side container up
var targRY= rightY + (imgHeight); // move right side container down
} else { // if at the last image reset to the first
var nextImg = 0;
var targLY= 0;
...