What is correct syntax for tweening two variables simultaneously?

  • Hi!

    i'm now studying the latest cool (God bless it!) Krpano release and find it FABULOUS!))

    Just try to understand how to tween, say, width and height of a container layer using the new tween(); Which is correct:

    this?

    Code
    tween(width,300,2|height,200,2);

    or this?

    Code
    tween(width|height, 300|200, 2);

    In both cases width and height are tweened to the needed values but they "jump" (seems default 0.5 time is used). But how to set the correct time for the tween?

    Thanks!

  • Hi,

    the second example is the correct one:

    Code
    tween(width|height, 300|200, 2);

    This should tween width to 300 and height to 200 in 2 seconds.

    There should be no 'jumps' in normal cases.

    The only case when there could be a 'jump' would be when mixing absolute values and percent values - the tween action itself can't resolve percent values to their absolute value (because it doesn't know a percent of what) - so when the value first was a percent value and then there is a absolute value to tween to, then there can be a jump at the start of the tween.

    Best regards,
    Klaus

  • It seems were posting at the same time
    When I sent my answer there was only the first post.

    Yes - the initial percent values are the problem here.

    In this case do:

    Code
    copy(width,pixelwidth); copy(height,pixelheight); tween(...);


    To get the absolute pixel sizes first before doing the tween.

    Edit:
    Normal the code above should already enough, but in this case that code will be called before the element was draw at least once, the updatepos() action should be additionally called to make sure that the pixelwidth and pixelheight values are calculated correctly:

    Code
    updatepos(); copy(width,pixelwidth); copy(height,pixelheight); tween(...);

    Best regards,
    Klaus

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!