PaulTheSwissGuy Posted February 19, 2021 Share Posted February 19, 2021 Hello people ! I made a simple .to tween, it's actually working if I open my live server and arrive on a new page. But I soon as I change my JavaScript, the tween is tweening from the middle of its animation, and not from the beginning, it's very frustrating. It was not happening before, this is kinda new. I made a video for you : https://www.youtube.com/watch?v=VWO7RofzSoE I'm coding with VS Code, with the live server extension + autosave on. The code is dead simple : HTML : <div class="cube"></div> CSS : .cube { background-color: orangered; width: 300px; height: 300px; } JS : const cube = document.querySelector(".cube") gsap.to(cube, { duration: 2, x: 300 }); Link to comment Share on other sites More sharing options...
elegantseagulls Posted February 19, 2021 Share Posted February 19, 2021 This seems like it's a dev env issue due to hot reloading and not a gsap issue, and I can't imagine it'll show up in produciton. If you want the animation to start from the beginning, you'll likely want to make a function that plays the timeline/tween from 0, or kills and resets the tween on refresh. Otherwise, you can use .fromTo to avoid this. 2 Link to comment Share on other sites More sharing options...
ZachSaucier Posted February 19, 2021 Share Posted February 19, 2021 Ya, it is definitely because of the live updates. 1 Link to comment Share on other sites More sharing options...
PaulTheSwissGuy Posted February 20, 2021 Author Share Posted February 20, 2021 Ok guys thank you ! It's mostly due to the "live server" Vs Code extension. But I can't code without it, it's so useful, and I love to change the value of the properties I animate, just to see how it looks. There is no solution at all ? Link to comment Share on other sites More sharing options...
PaulTheSwissGuy Posted February 20, 2021 Author Share Posted February 20, 2021 Ah ! Find a solution, it's working on Firefox ... But a solution for Chrome would be good How do you preview your animations with VS Code guys ? You are not using the Live Server for simple projects ? Link to comment Share on other sites More sharing options...
ZachSaucier Posted February 20, 2021 Share Posted February 20, 2021 1 hour ago, PaulTheSwissGuy said: How do you preview your animations with VS Code guys ? You are not using the Live Server for simple projects ? Nope. Save and refresh. 1 hour ago, PaulTheSwissGuy said: There is no solution at all ? There might be, but not related to GSAP specifically. It's not an issue with GSAP. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now