Use requestAnimationFrame for tweening.
Instead of using an arbitrary interval for tweening, we let the device decide the best animation frame rate. Where requestAnimationFrame is not available, this will default to 60 fps.
This commit is contained in:
@@ -12,12 +12,6 @@
|
||||
*/
|
||||
OpenLayers.Tween = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* Constant: INTERVAL
|
||||
* {int} Interval in milliseconds between 2 steps
|
||||
*/
|
||||
INTERVAL: 10,
|
||||
|
||||
/**
|
||||
* APIProperty: easing
|
||||
* {<OpenLayers.Easing>(Function)} Easing equation used for the animation
|
||||
@@ -58,10 +52,10 @@ OpenLayers.Tween = OpenLayers.Class({
|
||||
time: null,
|
||||
|
||||
/**
|
||||
* Property: interval
|
||||
* {int} Interval id returned by window.setInterval
|
||||
* Property: animationId
|
||||
* {int} Loop id returned by OpenLayers.Util.loopAnimation
|
||||
*/
|
||||
interval: null,
|
||||
animationId: null,
|
||||
|
||||
/**
|
||||
* Property: playing
|
||||
@@ -97,15 +91,14 @@ OpenLayers.Tween = OpenLayers.Class({
|
||||
this.duration = duration;
|
||||
this.callbacks = options.callbacks;
|
||||
this.time = 0;
|
||||
if (this.interval) {
|
||||
window.clearInterval(this.interval);
|
||||
this.interval = null;
|
||||
}
|
||||
OpenLayers.Util.stopAnimation(this.animationId);
|
||||
this.animationId = null;
|
||||
if (this.callbacks && this.callbacks.start) {
|
||||
this.callbacks.start.call(this, this.begin);
|
||||
}
|
||||
this.interval = window.setInterval(
|
||||
OpenLayers.Function.bind(this.play, this), this.INTERVAL);
|
||||
this.animationId = OpenLayers.Util.loopAnimation(
|
||||
OpenLayers.Function.bind(this.play, this)
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -121,8 +114,8 @@ OpenLayers.Tween = OpenLayers.Class({
|
||||
if (this.callbacks && this.callbacks.done) {
|
||||
this.callbacks.done.call(this, this.finish);
|
||||
}
|
||||
window.clearInterval(this.interval);
|
||||
this.interval = null;
|
||||
OpenLayers.Util.stopAnimation(this.animationId);
|
||||
this.animationId = null;
|
||||
this.playing = false;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user