Jump to content
Search Community

I wish roundProps would work here

Henry test
Moderator Tag

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

Hello

 

I'm trying to tween a value of an object like this:

 

var _obj = {v:0};
TweenMax.to(_obj, 1, {v:100, ease: Linear.easeNone, onUpdate:onTweenUpdate})
}

function onTweenUpdate ()
{
 console.log(_obj.v)
}

 

This works fine but what it actually needs are rounded values. I thought "roundProps" would come in handy but the following change causes an error in TweenMax.js:

 

TweenMax.to(_obj, 1, {v:100, roundProps:"v", ease: Linear.easeNone, onUpdate:onTweenUpdate})

 

Is this code wrong or does "roundProps" not work that way?

 

What I actually would like to do with it is tweening the "currentAnimationFrame" of an EaselJS BitmapAnimation.

 

I used the "onTweenUpdate" function from the example above together with Math.round() as a workaround. But it would be much nicer to tween the currentAnimationFrame directly.

 

Any ideas anyone?

 

Cheers

 

 

Henry

Link to comment
Share on other sites

Hello and thanks for your quick reply.

 

I used TweenMax.js. According to the documentation the plugin would be included. I just run a test with RoundPropsPlugin.js loaded as well. But it makes no difference. Well - a small difference: The error comes from RoundPropsPlugin.js now. ( Uncaught ReferenceError: _tween is not defined, line:56, Tested in Firefox and Chrome )

 

Your answer sounds like it should work? I reduced my code to the following copy/paste example. Perhaps it helps to find out what I'm doing wrong:

 

<!doctype html>
<html>
 <head>
<title>RoundProps Test</title>
<meta charset="utf-8" />
<script type="text/javascript" src="http://www.greensock.com/js/src/TweenMax.min.js"></script>
<script type="text/javascript">
  //<![CDATA[
var _obj = {v:0};
 TweenMax.to(_obj, 1, {v:100, roundProps:"v", ease: Linear.easeNone, onUpdate:onTweenUpdate})
 function onTweenUpdate ()
 {
console.log(_obj.v)
 }
//]]>
</script>
 </head>
 <body>
 </body>
</html>

 

 

 

Greetings

 

 

Henry

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...