sets loop to true by default

This commit is contained in:
Francisco Dans 2014-12-16 17:52:17 +01:00
parent 88ea3bee66
commit d82fe9d057
4 changed files with 27 additions and 14 deletions

14
dist/torque.full.js vendored

File diff suppressed because one or more lines are too long

6
dist/torque.js vendored

File diff suppressed because one or more lines are too long

View File

@ -20,6 +20,7 @@ var cancelAnimationFrame = global.cancelAnimationFrame
* animationDelay in seconds
*/
function Animator(callback, options) {
console.log(options);
if(!options.steps) {
throw new Error("steps option missing")
}
@ -29,10 +30,11 @@ var cancelAnimationFrame = global.cancelAnimationFrame
this._t0 = +new Date();
this.callback = callback;
this._time = 0.0;
this.options = torque.extend({
animationDelay: 0,
maxDelta: 0.2,
loop: true
loop: options.loop || true
}, this.options);
this.rescale();
@ -120,6 +122,9 @@ var cancelAnimationFrame = global.cancelAnimationFrame
this.time(this._time);
if(this.step() >= this.options.steps) {
this._time = 0;
if(!this.options.loop){
this.stop();
}
}
if(this.running) {
requestAnimationFrame(this._tick);
@ -2536,7 +2541,14 @@ L.TorqueLayer = L.CanvasLayer.extend({
var c = tile._tileCache = document.createElement('canvas');
c.width = c.height = tile_size;
pos = this.getTilePos(tile.coord);
c.getContext('2d').drawImage(this.getCanvas(), pos.x, pos.y, tile_size, tile_size, 0, 0, tile_size, tile_size);
// clip bounds, firefox raise an exception when try to get data from outside canvas
var x = Math.max(0, pos.x)
var y = Math.max(0, pos.y)
var w = Math.min(tile_size, this.getCanvas().width - x);
var h = Math.min(tile_size, this.getCanvas().height - y);
if (w > 0 && h > 0) {
c.getContext('2d').drawImage(this.getCanvas(), x, y, w, h, x - pos.x, y - pos.y, w, h);
}
}
}
}

View File

@ -27,10 +27,11 @@ var cancelAnimationFrame = global.cancelAnimationFrame
this._t0 = +new Date();
this.callback = callback;
this._time = 0.0;
this.options = torque.extend({
animationDelay: 0,
maxDelta: 0.2,
loop: options.loop
loop: options.loop || true
}, this.options);
this.rescale();
@ -119,7 +120,7 @@ var cancelAnimationFrame = global.cancelAnimationFrame
if(this.step() >= this.options.steps) {
this._time = 0;
if(!this.options.loop){
this.pause();
this.stop();
}
}
if(this.running) {