Remove ol.easing.elastic and ol.easing.bounce
And move the code to the animation example
This commit is contained in:
@@ -1,12 +1,38 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View2D');
|
goog.require('ol.View2D');
|
||||||
goog.require('ol.animation');
|
goog.require('ol.animation');
|
||||||
goog.require('ol.easing');
|
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
|
|
||||||
|
// from https://github.com/DmitryBaranovskiy/raphael
|
||||||
|
function bounce(t) {
|
||||||
|
var s = 7.5625, p = 2.75, l;
|
||||||
|
if (t < (1 / p)) {
|
||||||
|
l = s * t * t;
|
||||||
|
} else {
|
||||||
|
if (t < (2 / p)) {
|
||||||
|
t -= (1.5 / p);
|
||||||
|
l = s * t * t + 0.75;
|
||||||
|
} else {
|
||||||
|
if (t < (2.5 / p)) {
|
||||||
|
t -= (2.25 / p);
|
||||||
|
l = s * t * t + 0.9375;
|
||||||
|
} else {
|
||||||
|
t -= (2.625 / p);
|
||||||
|
l = s * t * t + 0.984375;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
// from https://github.com/DmitryBaranovskiy/raphael
|
||||||
|
function elastic(t) {
|
||||||
|
return Math.pow(2, -10 * t) * Math.sin((t - 0.075) * (2 * Math.PI) / 0.3) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
var london = ol.proj.transform([-0.12755, 51.507222], 'EPSG:4326', 'EPSG:3857');
|
var london = ol.proj.transform([-0.12755, 51.507222], 'EPSG:4326', 'EPSG:3857');
|
||||||
var moscow = ol.proj.transform([37.6178, 55.7517], 'EPSG:4326', 'EPSG:3857');
|
var moscow = ol.proj.transform([37.6178, 55.7517], 'EPSG:4326', 'EPSG:3857');
|
||||||
var istanbul = ol.proj.transform([28.9744, 41.0128], 'EPSG:4326', 'EPSG:3857');
|
var istanbul = ol.proj.transform([28.9744, 41.0128], 'EPSG:4326', 'EPSG:3857');
|
||||||
@@ -75,7 +101,7 @@ var elasticToMoscow = document.getElementById('elastic-to-moscow');
|
|||||||
elasticToMoscow.addEventListener('click', function() {
|
elasticToMoscow.addEventListener('click', function() {
|
||||||
var pan = ol.animation.pan({
|
var pan = ol.animation.pan({
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
easing: ol.easing.elastic,
|
easing: elastic,
|
||||||
source: /** @type {ol.Coordinate} */ (view.getCenter())
|
source: /** @type {ol.Coordinate} */ (view.getCenter())
|
||||||
});
|
});
|
||||||
map.beforeRender(pan);
|
map.beforeRender(pan);
|
||||||
@@ -86,7 +112,7 @@ var bounceToIstanbul = document.getElementById('bounce-to-istanbul');
|
|||||||
bounceToIstanbul.addEventListener('click', function() {
|
bounceToIstanbul.addEventListener('click', function() {
|
||||||
var pan = ol.animation.pan({
|
var pan = ol.animation.pan({
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
easing: ol.easing.bounce,
|
easing: bounce,
|
||||||
source: /** @type {ol.Coordinate} */ (view.getCenter())
|
source: /** @type {ol.Coordinate} */ (view.getCenter())
|
||||||
});
|
});
|
||||||
map.beforeRender(pan);
|
map.beforeRender(pan);
|
||||||
|
|||||||
@@ -3,34 +3,6 @@ goog.provide('ol.easing');
|
|||||||
goog.require('goog.fx.easing');
|
goog.require('goog.fx.easing');
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* from https://raw.github.com/DmitryBaranovskiy/raphael/master/raphael.js
|
|
||||||
* @param {number} t Input between 0 and 1.
|
|
||||||
* @return {number} Output between 0 and 1.
|
|
||||||
* @todo api
|
|
||||||
*/
|
|
||||||
ol.easing.bounce = function(t) {
|
|
||||||
var s = 7.5625, p = 2.75, l;
|
|
||||||
if (t < (1 / p)) {
|
|
||||||
l = s * t * t;
|
|
||||||
} else {
|
|
||||||
if (t < (2 / p)) {
|
|
||||||
t -= (1.5 / p);
|
|
||||||
l = s * t * t + 0.75;
|
|
||||||
} else {
|
|
||||||
if (t < (2.5 / p)) {
|
|
||||||
t -= (2.25 / p);
|
|
||||||
l = s * t * t + 0.9375;
|
|
||||||
} else {
|
|
||||||
t -= (2.625 / p);
|
|
||||||
l = s * t * t + 0.984375;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return l;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} t Input between 0 and 1.
|
* @param {number} t Input between 0 and 1.
|
||||||
* @return {number} Output between 0 and 1.
|
* @return {number} Output between 0 and 1.
|
||||||
@@ -47,17 +19,6 @@ ol.easing.easeIn = goog.fx.easing.easeIn;
|
|||||||
ol.easing.easeOut = goog.fx.easing.easeOut;
|
ol.easing.easeOut = goog.fx.easing.easeOut;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* from https://raw.github.com/DmitryBaranovskiy/raphael/master/raphael.js
|
|
||||||
* @param {number} t Input between 0 and 1.
|
|
||||||
* @return {number} Output between 0 and 1.
|
|
||||||
* @todo api
|
|
||||||
*/
|
|
||||||
ol.easing.elastic = function(t) {
|
|
||||||
return Math.pow(2, -10 * t) * Math.sin((t - 0.075) * (2 * Math.PI) / 0.3) + 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} t Input between 0 and 1.
|
* @param {number} t Input between 0 and 1.
|
||||||
* @return {number} Output between 0 and 1.
|
* @return {number} Output between 0 and 1.
|
||||||
|
|||||||
Reference in New Issue
Block a user