(I’ve moved this to a new topic, since it seems that it doesn’t have to do with viewport actions.)
There are two main problems:
- You have an On Scene Load action to run the Intro timeline. Therefore it will always run. This needs to be removed.
- But now everything is dark because the intro timeline has not been played. You actually need to “run” the timeline in some capacity; simply going to the end point would be enough.
I believe the root of your misunderstanding is probably reflected in the function name that you gave the code, “DisableTimelineFromPlaying.” This code does not disable it from playing, more specifically it plays the timeline if it has not been played before.
Stepping through the code:
var hasRunTimeline = localStorage.getItem('hasRunTimeline');
This first line fetched the flag from storage to see if it has or has not been run before.
if(hasRunTimeline != "true") {
This code is a conditional to ask, have we not been run?
hypeDocument.startTimelineNamed('Intro');
So if we haven’t been run, then let’s run the timeline.
localStorage.setItem('hasRunTimeline', "true");
And also lets set the flag to say that we have been run, so should we run the function again, we won’t enter into this block of code and start the timeline.
}
(end of conditional)
So now if you want to modify it to jump to the end of the timeline if we have been run before, you would just include an else
clause that does the Go To Timeline:
var hasRunTimeline = localStorage.getItem('hasRunTimeline');
if(hasRunTimeline != "true") {
hypeDocument.startTimelineNamed('Intro');
localStorage.setItem('hasRunTimeline', "true");
} else {
var endTime = hypeDocument.durationForTimelineNamed('Intro');
hypeDocument.goToTimeInTimelineNamed(endTime, 'Intro');
}
Secondarily you may also want to have the “Images” timeline restore its position? If so, you can likewise use localStorage to store the value instead of setting on the global window object, which will not persist across reloads.
So you would change the fetches for this value from:
window.currentTimeForScene1
to:
localStorage.getItem("currentTimeForScene1");
And the setter from:
window.currentTimeForScene1 = hypeDocument.currentTimeInTimelineNamed('Images');
to:
localStorage.setItem("currentTimeForScene1", hypeDocument.currentTimeInTimelineNamed('Images'));