Jump to content
Search Community

backgroundImage number bug

manar_mk test
Moderator Tag

Recommended Posts

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")'
})

 

  • Like 3
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...