Hi All,
I'm currently trying to create function that controls a sprite 4420px wide. The sprite is masked and only displays 170px width at any time. On a button click the sprite moves -170px to display the next image and so on. However when the last image of the sprite is reached I want to loop back to the first frame.
The if statement only seems to be recognised if the 'style.left == 0'.
Please see my function below any help would be appreciated.
Thanks
addListeners = function () {
angleLeft.addEventListener('click', angleLeftClick, false)
}
leftClick = new TimelineMax({
delay: 0,
});
function angleLeftClick() {
if (sprite.style.left == -4250) {
leftClick.to(sprite, 0, {
x: 0,
})
console.log("clicked");
}
else {
leftClick.to(sprite, 0, {
x: "-=170",
})
}
}