Jump to content
GreenSock

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

ThrowPropsPlugin.calculateTweenDuration()

ThrowPropsPlugin.calculateTweenDuration( target:Object, vars:Object, maxDuration:Number, minDuration:Number, overshootTolerance:Number ) : Number

[static] Analyzes various throwProps variables (like initial velocities, max/min values, and resistance) and determines the appropriate duration.

Parameters

target: Object

Target object whose properties the tween affects. This can be ANY object, not just a DOM element.

vars: Object

An object containing the end values of the properties you’re tweening, and it must also contain a throwProps object. For example, to create a tween that tweensobj.x at an initial velocity of 500 and obj.y at an initial velocity of -300 and applies a resistance of 80 and uses the Strong.easeOut easing equation and calls the methodtweenCompleteHandler when it is done, the vars object would look like: {throwProps:{x:500, y:-300, resistance:80}, ease:Strong.easeOut, onComplete:tweenCompleteHandler}.

maxDuration: Number

(default = 10) — Maximum duration (in seconds)

minDuration: Number

(default = 0.2) — Minimum duration (in seconds)

overshootTolerance: Number

(default = 1) — sets a maximum number of seconds that can be added to the tween’s duration (if necessary) to accommodate temporarily overshooting the end value before smoothly returning to it at the end of the tween. This can happen in situations where the initial velocity would normally cause it to exceed the maxor min values. An example of this would be in the iOS (iPhone or iPad) when you flick-scroll so quickly that the content would shoot past the end of the scroll area. Instead of jerking to a sudden stop when it reaches the edge, the content briefly glides past the max/min position and gently eases back into place. The larger the overshootTolerance the more leeway the tween has to temporarily shoot past the max/min if necessary.

Returns : Number

The duration (in seconds) that the tween should use.

Details

Analyzes various throwProps variables (like initial velocities, max/min values, and resistance) and determines the appropriate duration. Typically it is best to use theThrowPropsPlugin.to() method for this, but calculateTweenDuration() could be convenient if you want to create a TweenMax instance instead of a TweenLite instance (which is what throwPropsPlugin.to() returns).

Copyright 2017, GreenSock. All rights reserved. This work is subject to theterms of useor for Club GreenSock members, the software agreement that was issued with the membership.
×