Animating Width and Height

My guess is that to animate and images width and height (as in shrink or grow the image), I need to display it as an object and then manipulate contentWidth/contentHeight. Is that correct Are there other ways to do this

Thanks.



Answer this question

Animating Width and Height

  • Ashley Novak

    I did a bunch of testing. I get it now. The first method is stretching the image but within the boundaries of the image's original width and height.


  • lig

    By scale-to-fit you mean declare both width and height as auto


  • AlfonsAberg

    No; set contentWidth="scale-to-fit" and contentHeight="scale-to-fit".

    Then whatever you set width and height to, the backgroundImage will stretch / shrink to fit it.



  • Jabber

    Hmmm. So which method is more efficient/recommended

    1)
    document["foo"].style.animateProperty(“contentWidth”,”1920px;1980px”,4)


    2)
    contentWidth="scale-to-fit"
    document["foo"].style.animateProperty(“width”,”1920px;1980px”,4)


  • Ryan Launchbury

    Yes. The signature for this method is described on page Z304. Although not described very well at all :(


  • simon burgess

    the ",4) " at the end...is that 4 seconds


  • Malvino

    You can also just specify scale-to-fit for those two properties and then animate width and height as per normal.

  • Animating Width and Height