Move AnimationOptions to ol/View

This commit is contained in:
Tim Schaub
2018-03-11 10:37:57 -06:00
parent 70ff218a8e
commit 57d135e9f6
3 changed files with 24 additions and 94 deletions

View File

@@ -5,81 +5,6 @@
let olx;
/**
* @typedef {{
* center: (ol.Coordinate|undefined),
* zoom: (number|undefined),
* resolution: (number|undefined),
* rotation: (number|undefined),
* anchor: (ol.Coordinate|undefined),
* duration: (number|undefined),
* easing: (undefined|function(number):number)
* }}
*/
olx.AnimationOptions;
/**
* The center of the view at the end of the animation.
* @type {ol.Coordinate|undefined}
* @api
*/
olx.AnimationOptions.prototype.center;
/**
* The zoom level of the view at the end of the animation. This takes
* precedence over `resolution`.
* @type {number|undefined}
* @api
*/
olx.AnimationOptions.prototype.zoom;
/**
* The resolution of the view at the end of the animation. If `zoom` is also
* provided, this option will be ignored.
* @type {number|undefined}
* @api
*/
olx.AnimationOptions.prototype.resolution;
/**
* The rotation of the view at the end of the animation.
* @type {number|undefined}
* @api
*/
olx.AnimationOptions.prototype.rotation;
/**
* Optional anchor to remained fixed during a rotation or resolution animation.
* @type {ol.Coordinate|undefined}
* @api
*/
olx.AnimationOptions.prototype.anchor;
/**
* The duration of the animation in milliseconds (defaults to `1000`).
* @type {number|undefined}
* @api
*/
olx.AnimationOptions.prototype.duration;
/**
* The easing function used during the animation (defaults to {@link ol.easing.inAndOut}).
* The function will be called for each frame with a number representing a
* fraction of the animation's duration. The function should return a number
* between 0 and 1 representing the progress toward the destination state.
* @type {undefined|function(number):number}
* @api
*/
olx.AnimationOptions.prototype.easing;
/**
* Namespace.
* @type {Object}

View File

@@ -1,21 +1,4 @@
/**
* @typedef {Object} AnimationOptions
* @property {ol.Coordinate|undefined} center The center of the view at the end of the animation.
* @property {number|undefined} zoom The zoom level of the view at the end of the animation. This takes
* precedence over `resolution`.
* @property {number|undefined} resolution The resolution of the view at the end of the animation. If `zoom` is also
* provided, this option will be ignored.
* @property {number|undefined} rotation The rotation of the view at the end of the animation.
* @property {ol.Coordinate|undefined} anchor Optional anchor to remained fixed during a rotation or resolution animation.
* @property {number|undefined} duration The duration of the animation in milliseconds (defaults to `1000`).
* @property {undefined|function(number):number} easing The easing function used during the animation (defaults to {@link ol.easing.inAndOut}).
* The function will be called for each frame with a number representing a
* fraction of the animation's duration. The function should return a number
* between 0 and 1 representing the progress toward the destination state.
*/
/**
* @typedef {Object} control_AttributionOptions
* @property {string|undefined} className CSS class name. Default is `ol-attribution`.

View File

@@ -134,6 +134,28 @@ import Units from './proj/Units.js';
*/
/**
* @typedef {Object} AnimationOptions
* @property {ol.Coordinate|undefined} center The center of the view at the end of
* the animation.
* @property {number|undefined} zoom The zoom level of the view at the end of the
* animation. This takes precedence over `resolution`.
* @property {number|undefined} resolution The resolution of the view at the end
* of the animation. If `zoom` is also provided, this option will be ignored.
* @property {number|undefined} rotation The rotation of the view at the end of
* the animation.
* @property {ol.Coordinate|undefined} anchor Optional anchor to remained fixed
* during a rotation or resolution animation.
* @property {number|undefined} duration The duration of the animation in milliseconds
* (defaults to `1000`).
* @property {undefined|function(number):number} easing The easing function used
* during the animation (defaults to {@link ol.easing.inAndOut}).
* The function will be called for each frame with a number representing a
* fraction of the animation's duration. The function should return a number
* between 0 and 1 representing the progress toward the destination state.
*/
/**
* Default min zoom level for the map view.
* @type {number}
@@ -372,7 +394,7 @@ View.prototype.getUpdatedOptions_ = function(newOptions) {
* calling `view.setCenter()`, `view.setResolution()`, or `view.setRotation()`
* (or another method that calls one of these).
*
* @param {...(olx.AnimationOptions|function(boolean))} var_args Animation
* @param {...(module:ol/View~AnimationOptions|function(boolean))} var_args Animation
* options. Multiple animations can be run in series by passing multiple
* options objects. To run multiple animations in parallel, call the method
* multiple times. An optional callback can be provided as a final
@@ -412,7 +434,7 @@ View.prototype.animate = function(var_args) {
let rotation = this.getRotation();
const series = [];
for (let i = 0; i < animationCount; ++i) {
const options = /** @type {olx.AnimationOptions} */ (arguments[i]);
const options = /** @type {module:ol/View~AnimationOptions} */ (arguments[i]);
const animation = /** @type {module:ol/View~Animation} */ ({
start: start,