Having an issue getting timeline to see new variable. I have timeline items that are targeted with variables, which works fine with original variable set on page load. I have onClick function that sets new variable and then plays the timeline. I even log new variable in console before play command, which shows the new variable. The timeline plays, but loads the initial variable... not the new one that has been confirmed in console.
Any thoughts why the correct variable is not being used by the timeline? THANKS!
<script>
let activePage = ".Mdes";
let nextPage = ".Mcal";
let activeBut = ".desbut";
let nextBut = ".calbut";
let tlD2F = gsap.timeline({
paused: true,
});
tlD2F.to(activePage, {
zIndex: 0,
opacity: 0,
});
tlD2F.to(nextPage, {
zIndex: 30,
opacity: 1,
marginTop: "0vh",
duration:1,
}, );
tlD2F.to(activeBut, {
zIndex: 0,
opacity: 0,
}, 0);
tlD2F.to(nextBut, {
zIndex: 500,
opacity: 1,
}, 0);
document.getElementById('D2F').onclick = function(event) {
tlD2F.pause();
nextPage = ".Mfea";
nextBut = ".feabut";;
console.log("nextPage:", nextPage);
console.log("nextButton:", nextBut);
tlD2F.play(0);
};
</script>