Improve type checking in ol.animation

This commit is contained in:
Tom Payne
2013-04-30 21:29:10 +02:00
parent 59a4155651
commit d2979fc4ff
+28 -8
View File
@@ -17,7 +17,12 @@ ol.animation.bounce = function(options) {
var duration = goog.isDef(options.duration) ? options.duration : 1000; var duration = goog.isDef(options.duration) ? options.duration : 1000;
var easing = goog.isDef(options.easing) ? var easing = goog.isDef(options.easing) ?
options.easing : ol.easing.upAndDown; options.easing : ol.easing.upAndDown;
return function(map, frameState) { return (
/**
* @param {ol.Map} map Map.
* @param {?ol.FrameState} frameState Frame state.
*/
function(map, frameState) {
if (frameState.time < start) { if (frameState.time < start) {
frameState.animate = true; frameState.animate = true;
frameState.viewHints[ol.ViewHint.ANIMATING] += 1; frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
@@ -32,7 +37,7 @@ ol.animation.bounce = function(options) {
} else { } else {
return false; return false;
} }
}; });
}; };
@@ -48,7 +53,12 @@ ol.animation.pan = function(options) {
var duration = goog.isDef(options.duration) ? options.duration : 1000; var duration = goog.isDef(options.duration) ? options.duration : 1000;
var easing = goog.isDef(options.easing) ? var easing = goog.isDef(options.easing) ?
options.easing : ol.easing.inAndOut; options.easing : ol.easing.inAndOut;
return function(map, frameState) { return (
/**
* @param {ol.Map} map Map.
* @param {?ol.FrameState} frameState Frame state.
*/
function(map, frameState) {
if (frameState.time < start) { if (frameState.time < start) {
frameState.animate = true; frameState.animate = true;
frameState.viewHints[ol.ViewHint.ANIMATING] += 1; frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
@@ -65,7 +75,7 @@ ol.animation.pan = function(options) {
} else { } else {
return false; return false;
} }
}; });
}; };
@@ -80,7 +90,12 @@ ol.animation.rotate = function(options) {
var easing = goog.isDef(options.easing) ? var easing = goog.isDef(options.easing) ?
options.easing : ol.easing.inAndOut; options.easing : ol.easing.inAndOut;
return function(map, frameState) { return (
/**
* @param {ol.Map} map Map.
* @param {?ol.FrameState} frameState Frame state.
*/
function(map, frameState) {
if (frameState.time < start) { if (frameState.time < start) {
frameState.animate = true; frameState.animate = true;
frameState.viewHints[ol.ViewHint.ANIMATING] += 1; frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
@@ -96,7 +111,7 @@ ol.animation.rotate = function(options) {
} else { } else {
return false; return false;
} }
}; });
}; };
@@ -110,7 +125,12 @@ ol.animation.zoom = function(options) {
var duration = goog.isDef(options.duration) ? options.duration : 1000; var duration = goog.isDef(options.duration) ? options.duration : 1000;
var easing = goog.isDef(options.easing) ? var easing = goog.isDef(options.easing) ?
options.easing : ol.easing.inAndOut; options.easing : ol.easing.inAndOut;
return function(map, frameState) { return (
/**
* @param {ol.Map} map Map.
* @param {?ol.FrameState} frameState Frame state.
*/
function(map, frameState) {
if (frameState.time < start) { if (frameState.time < start) {
frameState.animate = true; frameState.animate = true;
frameState.viewHints[ol.ViewHint.ANIMATING] += 1; frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
@@ -126,5 +146,5 @@ ol.animation.zoom = function(options) {
} else { } else {
return false; return false;
} }
}; });
}; };