manar_mk Posted July 30, 2021 Share Posted July 30, 2021 I found a bug while working with gsap.to function. While passing backgroundImage path with numbers it adds some unexpected decimals. Any ways to avoid or fix this problem? See the Pen oNWddXe by manar_mk (@manar_mk) on CodePen Link to comment Share on other sites More sharing options...
OSUblake Posted July 30, 2021 Share Posted July 30, 2021 There's no bug. You can't animate a background image like that. What should the background be at 50%? GSAP is just doing string interpolation. It would be the same as doing this. It's just finding n-o-n-e and filling in the blanks. let obj = { backgroundImage: "none" }; gsap.to(obj, { backgroundImage: 'url("http://atlantaplanningguys.com/wp-content/uploads/2010/07/Image-2-the-numeral-4.jpg")', onUpdate() { console.log(obj.backgroundImage) } }); See the Pen oNWddpq by GreenSock (@GreenSock) on CodePen Just use .set() instead. gsap.set('.bg',{ backgroundImage: 'url("http://atlantaplanningguys.com/wp-content/uploads/2010/07/Image-2-the-numeral-4.jpg")' }) 3 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