migrated old manual test to new testing system. fixed tweening issues

This commit is contained in:
Eric Rowell
2013-12-05 23:10:42 -08:00
parent c7bb7d90ad
commit 50b3220812
35 changed files with 93 additions and 8773 deletions

View File

@@ -33,4 +33,54 @@ suite('Manual', function() {
});
// ======================================================
test('tween spline', function() {
var stage = addStage();
var layer = new Kinetic.Layer();
var spline = new Kinetic.Line({
points: [
73, 160,
340, 23,
500, 109,
300, 109
],
stroke: 'blue',
strokeWidth: 10,
lineCap: 'round',
lineJoin: 'round',
draggable: true,
tension: 1
});
layer.add(spline);
stage.add(layer);
var tween = new Kinetic.Tween({
node: spline,
duration: 1,
//x: 100,
points: [
200, 160,
200, 23,
500, 109,
100, 10
],
easing: Kinetic.Easings.BackEaseOut,
yoyo: true
});
// stage.getContent().addEventListener('mouseover', function() {
// tween.play();
// });
// stage.getContent().addEventListener('mouseout', function() {
// tween.reverse();
// });
tween.play();
});
});

View File

@@ -97,8 +97,7 @@
_context.closePath();
_context.fillStyle = 'red';
_context.fill();
},
listening: false
}
});
} else {

View File

@@ -16,7 +16,7 @@
<script src="../../dist/kinetic-dev.js"></script>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="lib/stats.js"></script>
<script src="../lib/stats.js"></script>
<script src="common/random-squares.js"></script>
</body>

View File

@@ -15,7 +15,7 @@
<div id="container"></div>
<script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v3.6.2.js"></script>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="lib/stats.js"></script>
<script src="../lib/stats.js"></script>
<script src="common/random-squares.js"></script>
</body>
</html>

View File

@@ -16,7 +16,7 @@
<script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.7.4.js"></script>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="lib/stats.js"></script>
<script src="../lib/stats.js"></script>
<script src="common/random-squares.js"></script>
</body>

View File

@@ -30,7 +30,9 @@
<script src="../node_modules/mocha/mocha.js"></script>
<script src="../node_modules/chai/chai.js"></script>
<script src="lib/stats.js"></script>
<script src="../dist/kinetic-dev.js"></script>
<!--<script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.7.4.js"></script>-->
<script src="runner.js"></script>
<!-- assets -->

View File

@@ -7,6 +7,17 @@ var assert = chai.assert,
assertionCount = 0,
assertions = document.createElement('em');
window.requestAnimFrame = (function(callback){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback){
window.setTimeout(callback, 1000 / 30);
};
})();
function init() {
// assert extenders so that we can count assertions
assert = function() {
@@ -38,6 +49,8 @@ function init() {
mochaStats.appendChild(li);
}
}
addStats();
}
@@ -45,6 +58,28 @@ function init() {
Kinetic.enableTrace = true;
function addStats() {
stats = new Stats();
stats.setMode(0);
stats.domElement.style.position = 'fixed';
stats.domElement.style.left = '0px';
stats.domElement.style.top = '0px';
document.getElementsByTagName('body')[0].appendChild( stats.domElement );
function animate(lastTime){
stats.begin();
requestAnimFrame(function(){
stats.end();
animate(lastTime);
});
}
animate();
}
function addStage() {
var container = document.createElement('div'),