mirror of
https://github.com/tweenjs/tween.js.git
synced 2026-02-01 17:27:10 +00:00
Only tween strings, numbers and arrays.
This commit is contained in:
parent
29d77a5f53
commit
fa2532d356
@ -285,7 +285,10 @@ TWEEN.Tween = function ( object ) {
|
||||
end = start + parseFloat(end, 10);
|
||||
}
|
||||
|
||||
_object[ property ] = start + ( end - start ) * value;
|
||||
// protect against non numeric properties.
|
||||
if ( typeof(end) === "number" ) {
|
||||
_object[ property ] = start + ( end - start ) * value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -83,8 +83,50 @@ test( "Tween non-null property", function() {
|
||||
|
||||
});
|
||||
|
||||
test( "Tween function property", function() {
|
||||
|
||||
var my_function = function() {};
|
||||
|
||||
var obj = { x: my_function },
|
||||
t = new TWEEN.Tween( obj );
|
||||
|
||||
t.to( { x: my_function } );
|
||||
t.start( 0 );
|
||||
t.update( 1000 );
|
||||
|
||||
ok( obj.x === my_function );
|
||||
|
||||
});
|
||||
|
||||
test( "Tween boolean property", function() {
|
||||
|
||||
var obj = { x: true },
|
||||
t = new TWEEN.Tween( obj );
|
||||
|
||||
t.to( { x: function() {} } );
|
||||
t.start( 0 );
|
||||
t.update( 1000 );
|
||||
|
||||
ok( typeof obj.x === "boolean" );
|
||||
ok( obj.x );
|
||||
|
||||
});
|
||||
|
||||
test( "Tween null property", function() {
|
||||
|
||||
var obj = { x: null },
|
||||
t = new TWEEN.Tween( obj );
|
||||
|
||||
t.to( { x: 2 }, 1000 );
|
||||
t.start( 0 );
|
||||
t.update( 1000 );
|
||||
|
||||
deepEqual( obj.x, 2 );
|
||||
|
||||
});
|
||||
|
||||
test( "Tween undefined property", function() {
|
||||
|
||||
var obj = { },
|
||||
t = new TWEEN.Tween( obj );
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user