Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - What is a Tween object?

Tags:

I have come across this term for quite a few times, but I can't find detailed definition about it.
For example, parameter fx in some jQuery methods is Tween.init.

Can anyone offer some help ?

like image 873
CDT Avatar asked May 14 '13 10:05

CDT


People also ask

What is a Tween in code?

The Tween class is the class which handles all the animation, and can animate all properties that have a numeric value. These properties could be: x position. y position. alpha (opacity)

What is Tween in Javascript?

Tween manages the shift from one property value to another property value for an object. Tween - Abbreviation for "In-between". In animation, tweens are the frames that depict a character's or objects' motion between key frames.

What does jQuery .show do?

The show() Method in jQuery is used to display the hidden and selected elements. Note: This method display the hidden elements which are using CSS display: none property. The elements are not visible whose visibility is hidden.

What is jQuery animate?

Definition and Usage The animate() method performs a custom animation of a set of CSS properties. This method changes an element from one state to another with CSS styles. The CSS property value is changed gradually, to create an animated effect. Only numeric values can be animated (like "margin:30px").


2 Answers

Tween is used in animation in JQuery. Tween.js being a standalone example of Tween.

Short for in-betweening, the process of generating intermediate frames between two images to give the appearance that the first image evolves smoothly into the second image. Tweening is a key process in all types of animation, including computer animation. Sophisticated animation software enables you to identify specific objects in an image and define how they should move and change during the tweening process.

From http://www.webopedia.com/TERM/T/tweening.html

like image 78
Ryan McDonough Avatar answered Oct 20 '22 23:10

Ryan McDonough


The objects and methods used around jQuery animations - tweens, tweeners, hooks, prefilters, etc - are very poorly documented, even though they appear to be part of the public API. Perhaps it helps to list some resources here.

  • There is a little bit of info in a presentation on jQuery animation (slides), by Corey Frang, a memeber of the jQuery team. Just two terse slides, actually. Jump in right here.
  • There is much more detail in the draft documentation for jQuery 1.8 Effects, published by the same guy. This is actually the single most helpful resource on the topic I was able to find.

This is what the draft documentation has to say about the properties and methods of the Tween object:

  • elem: The element being animated
  • prop: The property being animated
  • easing: The easing used
  • options: A reference to the animation options
  • start: The starting value of the tween
  • now: The current value of the tween
  • end: The ending value of the tween
  • unit: The CSS unit for the tween
  • cur(): Reads the current value for property from the element
  • run( progress ): progress is a number from 0 to 1. Updates the value for the property on the animated element.

A Tween instance is passed to the step callback of a jQuery animation and can be used to manipulate the animation while it is in progress. Knowing about the Tween API might come in handy there.

like image 20
hashchange Avatar answered Oct 21 '22 01:10

hashchange