// --- 1. DATA GATHERING & VALIDATION ---
const currentTime = getVar("CurrentTime");
const startMs = getVar("Startms");
const stopMs = getVar("Stopms");
// --- 2. ONE-TIME ANIMATION SETUP (MODIFIED) ---
// This part now stores the target element globally so we can access it later.
if (!window.myAnimation) {
// Find the element once and store it on the window object for later access
window.myAnimatedElement = document.querySelector('[data-model-id="5cyP2VVRpJQ"]');
if (window.myAnimatedElement) {
window.myAnimation = gsap.timeline({ paused: true });
window.myAnimation.to(window.myAnimatedElement, {
duration: 4,
xPercent: 250,
scale: 1.3,
ease: "none"
});
}
}
// --- 3. PROGRESS CALCULATION ---
let progress = 0;
const activeDuration = stopMs - startMs;
// This is the main logic path
if (currentTime <= startMs) {
progress = 0;
} else if (currentTime >= stopMs) {
progress = 1;
} else {
// Only calculate progress when we are between start and stop.
progress = (currentTime - startMs) / activeDuration;
}
// --- 4. APPLY THE PROGRESS ---
//console.log(`Final Progress: ${progress.toFixed(3)}`);
window.myAnimation.progress(progress);