Improve type checking in ol.animation
This commit is contained in:
+88
-68
@@ -17,22 +17,27 @@ 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 (
|
||||||
if (frameState.time < start) {
|
/**
|
||||||
frameState.animate = true;
|
* @param {ol.Map} map Map.
|
||||||
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
* @param {?ol.FrameState} frameState Frame state.
|
||||||
return true;
|
*/
|
||||||
} else if (frameState.time < start + duration) {
|
function(map, frameState) {
|
||||||
var delta = easing((frameState.time - start) / duration);
|
if (frameState.time < start) {
|
||||||
var deltaResolution = resolution - frameState.view2DState.resolution;
|
frameState.animate = true;
|
||||||
frameState.animate = true;
|
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
||||||
frameState.view2DState.resolution += delta * deltaResolution;
|
return true;
|
||||||
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
} else if (frameState.time < start + duration) {
|
||||||
return true;
|
var delta = easing((frameState.time - start) / duration);
|
||||||
} else {
|
var deltaResolution = resolution - frameState.view2DState.resolution;
|
||||||
return false;
|
frameState.animate = true;
|
||||||
}
|
frameState.view2DState.resolution += delta * deltaResolution;
|
||||||
};
|
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -48,24 +53,29 @@ 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 (
|
||||||
if (frameState.time < start) {
|
/**
|
||||||
frameState.animate = true;
|
* @param {ol.Map} map Map.
|
||||||
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
* @param {?ol.FrameState} frameState Frame state.
|
||||||
return true;
|
*/
|
||||||
} else if (frameState.time < start + duration) {
|
function(map, frameState) {
|
||||||
var delta = 1 - easing((frameState.time - start) / duration);
|
if (frameState.time < start) {
|
||||||
var deltaX = sourceX - frameState.view2DState.center[0];
|
frameState.animate = true;
|
||||||
var deltaY = sourceY - frameState.view2DState.center[1];
|
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
||||||
frameState.animate = true;
|
return true;
|
||||||
frameState.view2DState.center[0] += delta * deltaX;
|
} else if (frameState.time < start + duration) {
|
||||||
frameState.view2DState.center[1] += delta * deltaY;
|
var delta = 1 - easing((frameState.time - start) / duration);
|
||||||
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
var deltaX = sourceX - frameState.view2DState.center[0];
|
||||||
return true;
|
var deltaY = sourceY - frameState.view2DState.center[1];
|
||||||
} else {
|
frameState.animate = true;
|
||||||
return false;
|
frameState.view2DState.center[0] += delta * deltaX;
|
||||||
}
|
frameState.view2DState.center[1] += delta * deltaY;
|
||||||
};
|
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -80,23 +90,28 @@ 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 (
|
||||||
if (frameState.time < start) {
|
/**
|
||||||
frameState.animate = true;
|
* @param {ol.Map} map Map.
|
||||||
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
* @param {?ol.FrameState} frameState Frame state.
|
||||||
return true;
|
*/
|
||||||
} else if (frameState.time < start + duration) {
|
function(map, frameState) {
|
||||||
var delta = 1 - easing((frameState.time - start) / duration);
|
if (frameState.time < start) {
|
||||||
var deltaRotation =
|
frameState.animate = true;
|
||||||
sourceRotation - frameState.view2DState.rotation;
|
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
||||||
frameState.animate = true;
|
return true;
|
||||||
frameState.view2DState.rotation += delta * deltaRotation;
|
} else if (frameState.time < start + duration) {
|
||||||
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
var delta = 1 - easing((frameState.time - start) / duration);
|
||||||
return true;
|
var deltaRotation =
|
||||||
} else {
|
sourceRotation - frameState.view2DState.rotation;
|
||||||
return false;
|
frameState.animate = true;
|
||||||
}
|
frameState.view2DState.rotation += delta * deltaRotation;
|
||||||
};
|
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -110,21 +125,26 @@ 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 (
|
||||||
if (frameState.time < start) {
|
/**
|
||||||
frameState.animate = true;
|
* @param {ol.Map} map Map.
|
||||||
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
* @param {?ol.FrameState} frameState Frame state.
|
||||||
return true;
|
*/
|
||||||
} else if (frameState.time < start + duration) {
|
function(map, frameState) {
|
||||||
var delta = 1 - easing((frameState.time - start) / duration);
|
if (frameState.time < start) {
|
||||||
var deltaResolution =
|
frameState.animate = true;
|
||||||
sourceResolution - frameState.view2DState.resolution;
|
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
||||||
frameState.animate = true;
|
return true;
|
||||||
frameState.view2DState.resolution += delta * deltaResolution;
|
} else if (frameState.time < start + duration) {
|
||||||
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
var delta = 1 - easing((frameState.time - start) / duration);
|
||||||
return true;
|
var deltaResolution =
|
||||||
} else {
|
sourceResolution - frameState.view2DState.resolution;
|
||||||
return false;
|
frameState.animate = true;
|
||||||
}
|
frameState.view2DState.resolution += delta * deltaResolution;
|
||||||
};
|
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user