Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
kurkumakako

keyword css values

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi! I've ran into this.

< var div = document.createElement('div');
< TweenMax.set(div, {backgroundSize: 'cover'});
< console.log(div.style.backgroundSize);
> "50% 0px"

It's should be "cover", isn't it?

Link to comment
Share on other sites

Hi and welcome to forums,

 

TweenMax.set() is basically a zero-duration tween. It will tween for zero seconds ( immediately rendering ) values that are tweenable. backgroundSize takes several options, from which some are tweenable ( like backgroundSize: 10% 50% ) and some are not ( like backgroundSize: cover ). I think TweenMax can't tween that value so it just fallbacks to some value that is tweenable, in this case 50% 0px ).  

Link to comment
Share on other sites

Yes, it appears that when you specify "cover" or any string it is generating the 50% 0px value, which isn't proper.

 

We will look into this further and get back to you. 

 

Thank you.

  • Like 1
Link to comment
Share on other sites

Yep, Looks like both Chrome and Firefox report the same value for cover: 50% 0px

 

I don't know if this helps.. but when i look at the background-size property, it looks like keyword values are not animatable, even though GSAP can animate any property and object! B)

 

Taken from MDN background-size docs:

  • Animatiable:
    yes, as a repeatable list of a simple list of a length, percentage or calc(); when both values are lengths, they are interpolated as lengths; when both values are percentages, they are interpolated as percentages; otherwise, both values are converted into a calc() function that is the sum of a length and a percentage (each possibly zero), and these calc() functions have each half interpolated as real numbers. This means keyword values are not animatable.
     
  • If the background-size is contain or cover.
    The image is rendered, preserving its intrinsic proportion, at the largest size contained within, or covering, the background positioning area.  If the image has no intrinsic proportion, then it is rendered at the size of the background positioning area.

Just my two cents, that are worth one cent:)

  • Like 1
Link to comment
Share on other sites

After further review, we are going to have look into supporting background-size keywords at a later time. Just a matter of managing a number of very significant priorities that we have for the platform. 

 

Will using "100% 100%" work for you? It seems that will currently work with both tweens and set:

http://codepen.io/GreenSock/pen/pvLKD

 

Thanks again for pointing out the issue. We will keep it on our list.

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.

×