If I was going to do this in JS instead of the timelines.
I would put all the slides in a single group and offset to the right side of the scene except slide 1 which will be showing.
I would then just use the Javascript to move the group.
For the buttons we simply use the symbol name of the buttons to help us calculate the amount of left movement we need. (The symbol names all end in a index number )
In both functions we try and control some of the behaviour if people mash the buttons or arrows.
Buttons code ( all buttons point to this function)
var slider = hypeDocument.getElementById('slider')
hypeDocument.setElementProperty(slider, 'opacity', 0, 1, 'easeinout')//-- fade out
var thisSlide = Number(hypeDocument.getSymbolInstanceById(element.id).symbolName().slice(-2)); //-- get the last 2 characters of the button's symbol name as a number.
var newLeft = 0 - (657 * (thisSlide -1)) //-- 657 is the width of each lide. we Times that by the number from the button.
//-- slide
setTimeout(function(){
if (hypeDocument.getElementById('slider').style.opacity == 0) { //-- try not to re slide two soon
hypeDocument.setElementProperty(slider, 'left', newLeft) //-- slide to new left.
}
hypeDocument.setElementProperty(slider, 'opacity', 1, 1.0, 'easeinout')//-- fade back in
}, 1010);
For the arrows we just need to advance or decrease the left by a single amount each time.
But we also need to put limiters on the max/min left
Arrow code ( Both arrows point to this function)
var rightArrow = hypeDocument.getElementById('right')
var leftArrow = hypeDocument.getElementById('left')
var min_Left =657
var max_Left = -6570
//-- disable arrows so we do not go to early and get wrong left.
rightArrow.style.pointerEvents = "none"
leftArrow.style.pointerEvents = "none"
var slider = hypeDocument.getElementById('slider')//-- Group the slides are in
var currentLeft = hypeDocument.getElementProperty(slider, 'left')
window.newLeft = Math.floor(currentLeft + min_Left ) //go left
if (element.id == "right"){ //go right
window.newLeft = Math.floor(currentLeft - min_Left)
}
if (window.newLeft < min_Left && window.newLeft > max_Left ) { //-- limit going to far left or to far right
hypeDocument.setElementProperty(slider, 'left', window.newLeft, 1, 'easeinout')
}
setTimeout(function(){ //-- reste arrows
rightArrow.style.pointerEvents = "auto"
leftArrow.style.pointerEvents = "auto"
}, 1050);
TheTrail_gallery_MHv1.hype.zip (682.5 KB)