adds tween and easing classes (with algorithms from Robert Penner) to handle animation
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6097 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
62
tests/test_Tween.html
Normal file
62
tests/test_Tween.html
Normal file
@@ -0,0 +1,62 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_Tween_constructor(t) {
|
||||
t.plan(3);
|
||||
|
||||
var tween = new OpenLayers.Tween();
|
||||
t.ok(tween instanceof OpenLayers.Tween,
|
||||
"new OpenLayers.Tween returns object" );
|
||||
t.eq(typeof tween.easing, "function",
|
||||
"constructor sets easing correctly");
|
||||
t.eq(typeof tween.start, "function", "tween has a start function");
|
||||
}
|
||||
|
||||
function test_Tween_start(t) {
|
||||
t.plan(5);
|
||||
|
||||
var tween = new OpenLayers.Tween();
|
||||
|
||||
var start = {foo: 0, bar: 10};
|
||||
var finish = {foo: 10, bar: 0};
|
||||
var _start = false;
|
||||
var _done = false;
|
||||
var _eachStep = false;
|
||||
var callbacks = {
|
||||
start: function() {
|
||||
_start = true;
|
||||
},
|
||||
done: function() {
|
||||
_done = true;
|
||||
},
|
||||
eachStep: function() {
|
||||
_eachStep = true;
|
||||
}
|
||||
}
|
||||
tween.start(start, finish, 10, {callbacks: callbacks});
|
||||
t.ok(tween.interval != null, "interval correctly set");
|
||||
t.delay_call(0.8, function() {
|
||||
t.eq(_start, true, "start callback called");
|
||||
t.eq(_done, true, "finish callback called");
|
||||
t.eq(_eachStep, true, "eachStep callback called");
|
||||
t.eq(tween.time, 11, "Number of steps reached is correct");
|
||||
});
|
||||
}
|
||||
|
||||
function test_Tween_stop(t) {
|
||||
t.plan(1);
|
||||
|
||||
var tween = new OpenLayers.Tween();
|
||||
tween.interval = window.setInterval(function() {}, 10);
|
||||
tween.stop();
|
||||
t.eq(tween.interval, null, "tween correctly stopped");
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width:500px;height:500px"></div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user