Not 100% on what you want but ..
Always suggest moving any animations off the main timeline where you can.
This will always give you more control.
We have timeline mover that does all the animation
We start the timeline mover from the main time line.
On first scene load, we add listeners to the Hype Doc and not globally to the window.
The listeners are for mouse enter, mouse move, mouse out.
If we enter and we pause the animation and start 5s timer. after timer the animation will start again.
If we move within the hype doc we pause the animation and start 5s timer. after timer the animation will start again.
If we move out off the hype doc we restart the animation.
We clear the time as needed.
.
var timer = null;
const info = hypeDocument.getElementById('info')
const timerText_ = hypeDocument.getElementById('timerText')
mouseMoved = function (e) {
hypeDocument.pauseTimelineNamed('mover')
info.innerHTML = "pausing Timeline"
clearTimer()
timer = window.setTimeout(restartTimeline, 5000);//("Restarting After Timeout")
timerText_.innerHTML = "Timer Started"
}
restartTimeline = function (e) {
clearTimer()
hypeDocument.continueTimelineNamed('mover', hypeDocument.kDirectionForward, false);
info.innerHTML = "restart Timeline "
}
function clearTimer(e) {
if (timer != null) {
window.clearTimeout(timer);
timer = null;
timerText_.innerHTML = "Timer Cleard"
}
}
var theDoc = document.getElementById( hypeDocument.documentId() )
theDoc.addEventListener('mousemove', mouseMoved);// pausing on MouseEMoved
theDoc.addEventListener('mouseenter', mouseMoved); // pausing on MouseEntered
theDoc.addEventListener('mouseout', restartTimeline);// Restarting on Mouse Out"
When the animation competes we go to the next scene which has an on scene load that clears the listeners
var theDoc = document.getElementById( hypeDocument.documentId() )
theDoc.removeEventListener("mousemove", mouseMoved, false);
theDoc.removeEventListener("mouseenter", mouseMoved, false);
theDoc.removeEventListener("mouseout", restartTimeline, false);
Stop Timelline_.hype.zip (25.3 KB)