Skip to content

onedayitwillmake/tween.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tween.js

Javascript Tweening Engine

Flattr this

Super simple, fast and easy to use tweening engine which incorporates optimised Robert Penner's equations.

We are still developing this so the API might change from commit to commit.

Examples

Simplest possible example Graphs Black and red Bars hello world

Projects using tween.js

Floweroscope The Wilderness Downtown Linechart

Usage

Download the minified library and include it in your html.

<script type="text/javascript" src="js/Tween.js"></script>

The following code creates a Tween which will change the 'x' attribute in a position variable, so that it goes from 50 to 400 in 2 seconds. The anonymous function set up with an interval will update the screen so that we can see something happening:

<script type="text/javascript">

	var position = {x: 50, y: 0};
	var tween = new TWEEN.Tween(position).to({x: 400}, 2000).start();
	var output = document.createElement('div');
	var target = document.getElementById('target');
	target.appendChild(output);

	setInterval(function() {

		TWEEN.update();

		var newX = position.x;

		output.innerHTML = 'x == ' + Math.round(newX);
		target.style.left = (newX) + 'px';

	}, 1000 / 60);

</script>

Note: this corresponds to the example 04_simplest.html that you can find in the examples folder.

Have a look at that folder to discover more functionalities of the library!

Contributors

People who have contributed directly or indirectly to this project :-D

sole, mrdoob, Robert Eisele, Robert Penner, Philippe Elsass

About

Javascript tweening engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published