From 061e0b66189b5f2fc8689b184ae4e5bbb7b301c5 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 14 Dec 2017 08:42:36 +0100 Subject: [PATCH] Named exports from ol/easing --- examples/animation.js | 10 +++++----- examples/feature-animation.js | 6 +++--- src/ol/Tile.js | 4 ++-- src/ol/View.js | 4 ++-- src/ol/control/Rotate.js | 4 ++-- src/ol/control/Zoom.js | 4 ++-- src/ol/control/ZoomSlider.js | 6 +++--- src/ol/easing.js | 28 +++++++++++++--------------- src/ol/interaction/DragPan.js | 4 ++-- src/ol/interaction/DragZoom.js | 4 ++-- src/ol/interaction/Interaction.js | 8 ++++---- src/ol/interaction/MouseWheelZoom.js | 8 ++++---- 12 files changed, 44 insertions(+), 46 deletions(-) diff --git a/examples/animation.js b/examples/animation.js index b1191ae914..d79104da8b 100644 --- a/examples/animation.js +++ b/examples/animation.js @@ -1,6 +1,6 @@ import _ol_Map_ from '../src/ol/Map.js'; import _ol_View_ from '../src/ol/View.js'; -import _ol_easing_ from '../src/ol/easing.js'; +import {easeIn, easeOut} from '../src/ol/easing.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_proj_ from '../src/ol/proj.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js'; @@ -79,11 +79,11 @@ onClick('rotate-around-rome', function() { view.animate({ rotation: rotation + Math.PI, anchor: rome, - easing: _ol_easing_.easeIn + easing: easeIn }, { rotation: rotation + 2 * Math.PI, anchor: rome, - easing: _ol_easing_.easeOut + easing: easeOut }); }); @@ -119,11 +119,11 @@ onClick('spin-to-rome', function() { center[1] + (rome[1] - center[1]) / 2 ], rotation: Math.PI, - easing: _ol_easing_.easeIn + easing: easeIn }, { center: rome, rotation: 2 * Math.PI, - easing: _ol_easing_.easeOut + easing: easeOut }); }); diff --git a/examples/feature-animation.js b/examples/feature-animation.js index 1ba80c1194..3c42fbf8b2 100644 --- a/examples/feature-animation.js +++ b/examples/feature-animation.js @@ -3,7 +3,7 @@ import _ol_Map_ from '../src/ol/Map.js'; import _ol_Observable_ from '../src/ol/Observable.js'; import _ol_View_ from '../src/ol/View.js'; import _ol_control_ from '../src/ol/control.js'; -import _ol_easing_ from '../src/ol/easing.js'; +import {easeOut} from '../src/ol/easing.js'; import _ol_geom_Point_ from '../src/ol/geom/Point.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; @@ -64,8 +64,8 @@ function flash(feature) { var elapsed = frameState.time - start; var elapsedRatio = elapsed / duration; // radius will be 5 at start and 30 at end. - var radius = _ol_easing_.easeOut(elapsedRatio) * 25 + 5; - var opacity = _ol_easing_.easeOut(1 - elapsedRatio); + var radius = easeOut(elapsedRatio) * 25 + 5; + var opacity = easeOut(1 - elapsedRatio); var style = new _ol_style_Style_({ image: new _ol_style_Circle_({ diff --git a/src/ol/Tile.js b/src/ol/Tile.js index cf659b72fc..23e6b7f10e 100644 --- a/src/ol/Tile.js +++ b/src/ol/Tile.js @@ -3,7 +3,7 @@ */ import {inherits} from './index.js'; import _ol_TileState_ from './TileState.js'; -import _ol_easing_ from './easing.js'; +import {easeIn} from './easing.js'; import _ol_events_EventTarget_ from './events/EventTarget.js'; import _ol_events_EventType_ from './events/EventType.js'; @@ -203,7 +203,7 @@ _ol_Tile_.prototype.getAlpha = function(id, time) { if (delta >= this.transition_) { return 1; } - return _ol_easing_.easeIn(delta / this.transition_); + return easeIn(delta / this.transition_); }; /** diff --git a/src/ol/View.js b/src/ol/View.js index 5146cbfcb6..b492b2f260 100644 --- a/src/ol/View.js +++ b/src/ol/View.js @@ -12,7 +12,7 @@ import _ol_ViewProperty_ from './ViewProperty.js'; import _ol_array_ from './array.js'; import _ol_asserts_ from './asserts.js'; import _ol_coordinate_ from './coordinate.js'; -import _ol_easing_ from './easing.js'; +import {inAndOut} from './easing.js'; import {getForViewAndSize, getCenter, getHeight, getWidth, isEmpty} from './extent.js'; import _ol_geom_GeometryType_ from './geom/GeometryType.js'; import _ol_geom_Polygon_ from './geom/Polygon.js'; @@ -306,7 +306,7 @@ _ol_View_.prototype.animate = function(var_args) { complete: false, anchor: options.anchor, duration: options.duration !== undefined ? options.duration : 1000, - easing: options.easing || _ol_easing_.inAndOut + easing: options.easing || inAndOut }); if (options.center) { diff --git a/src/ol/control/Rotate.js b/src/ol/control/Rotate.js index 43f7f70582..4346b17e92 100644 --- a/src/ol/control/Rotate.js +++ b/src/ol/control/Rotate.js @@ -4,7 +4,7 @@ import _ol_control_Control_ from '../control/Control.js'; import _ol_css_ from '../css.js'; -import _ol_easing_ from '../easing.js'; +import {easeOut} from '../easing.js'; import _ol_events_ from '../events.js'; import _ol_events_EventType_ from '../events/EventType.js'; import {inherits} from '../index.js'; @@ -127,7 +127,7 @@ _ol_control_Rotate_.prototype.resetNorth_ = function() { view.animate({ rotation: 0, duration: this.duration_, - easing: _ol_easing_.easeOut + easing: easeOut }); } else { view.setRotation(0); diff --git a/src/ol/control/Zoom.js b/src/ol/control/Zoom.js index 1ede3bd3e4..177e53fa0f 100644 --- a/src/ol/control/Zoom.js +++ b/src/ol/control/Zoom.js @@ -6,7 +6,7 @@ import _ol_events_ from '../events.js'; import _ol_events_EventType_ from '../events/EventType.js'; import _ol_control_Control_ from '../control/Control.js'; import _ol_css_ from '../css.js'; -import _ol_easing_ from '../easing.js'; +import {easeOut} from '../easing.js'; /** * @classdesc @@ -113,7 +113,7 @@ _ol_control_Zoom_.prototype.zoomByDelta_ = function(delta) { view.animate({ resolution: newResolution, duration: this.duration_, - easing: _ol_easing_.easeOut + easing: easeOut }); } else { view.setResolution(newResolution); diff --git a/src/ol/control/ZoomSlider.js b/src/ol/control/ZoomSlider.js index f8714dbc33..4e75742455 100644 --- a/src/ol/control/ZoomSlider.js +++ b/src/ol/control/ZoomSlider.js @@ -7,7 +7,7 @@ import {inherits} from '../index.js'; import _ol_ViewHint_ from '../ViewHint.js'; import _ol_control_Control_ from '../control/Control.js'; import _ol_css_ from '../css.js'; -import _ol_easing_ from '../easing.js'; +import {easeOut} from '../easing.js'; import _ol_events_ from '../events.js'; import _ol_events_Event_ from '../events/Event.js'; import _ol_events_EventType_ from '../events/EventType.js'; @@ -239,7 +239,7 @@ _ol_control_ZoomSlider_.prototype.handleContainerClick_ = function(event) { view.animate({ resolution: view.constrainResolution(resolution), duration: this.duration_, - easing: _ol_easing_.easeOut + easing: easeOut }); }; @@ -293,7 +293,7 @@ _ol_control_ZoomSlider_.prototype.handleDraggerEnd_ = function(event) { view.animate({ resolution: view.constrainResolution(this.currentResolution_), duration: this.duration_, - easing: _ol_easing_.easeOut + easing: easeOut }); this.dragging_ = false; diff --git a/src/ol/easing.js b/src/ol/easing.js index 39a265dc15..aebd94a886 100644 --- a/src/ol/easing.js +++ b/src/ol/easing.js @@ -1,7 +1,6 @@ /** * @module ol/easing */ -var _ol_easing_ = {}; /** @@ -10,9 +9,9 @@ var _ol_easing_ = {}; * @return {number} Output between 0 and 1. * @api */ -_ol_easing_.easeIn = function(t) { +export function easeIn(t) { return Math.pow(t, 3); -}; +} /** @@ -21,9 +20,9 @@ _ol_easing_.easeIn = function(t) { * @return {number} Output between 0 and 1. * @api */ -_ol_easing_.easeOut = function(t) { - return 1 - _ol_easing_.easeIn(1 - t); -}; +export function easeOut(t) { + return 1 - easeIn(1 - t); +} /** @@ -32,9 +31,9 @@ _ol_easing_.easeOut = function(t) { * @return {number} Output between 0 and 1. * @api */ -_ol_easing_.inAndOut = function(t) { +export function inAndOut(t) { return 3 * t * t - 2 * t * t * t; -}; +} /** @@ -43,9 +42,9 @@ _ol_easing_.inAndOut = function(t) { * @return {number} Output between 0 and 1. * @api */ -_ol_easing_.linear = function(t) { +export function linear(t) { return t; -}; +} /** @@ -56,11 +55,10 @@ _ol_easing_.linear = function(t) { * @return {number} Output between 0 and 1. * @api */ -_ol_easing_.upAndDown = function(t) { +export function upAndDown(t) { if (t < 0.5) { - return _ol_easing_.inAndOut(2 * t); + return inAndOut(2 * t); } else { - return 1 - _ol_easing_.inAndOut(2 * (t - 0.5)); + return 1 - inAndOut(2 * (t - 0.5)); } -}; -export default _ol_easing_; +} diff --git a/src/ol/interaction/DragPan.js b/src/ol/interaction/DragPan.js index dec18402c5..989783e564 100644 --- a/src/ol/interaction/DragPan.js +++ b/src/ol/interaction/DragPan.js @@ -4,7 +4,7 @@ import {inherits} from '../index.js'; import _ol_ViewHint_ from '../ViewHint.js'; import _ol_coordinate_ from '../coordinate.js'; -import _ol_easing_ from '../easing.js'; +import {easeOut} from '../easing.js'; import _ol_events_condition_ from '../events/condition.js'; import _ol_functions_ from '../functions.js'; import _ol_interaction_Pointer_ from '../interaction/Pointer.js'; @@ -120,7 +120,7 @@ _ol_interaction_DragPan_.handleUpEvent_ = function(mapBrowserEvent) { view.animate({ center: view.constrainCenter(dest), duration: 500, - easing: _ol_easing_.easeOut + easing: easeOut }); } view.setHint(_ol_ViewHint_.INTERACTING, -1); diff --git a/src/ol/interaction/DragZoom.js b/src/ol/interaction/DragZoom.js index 8e2ae0d7b9..b2e2b099d1 100644 --- a/src/ol/interaction/DragZoom.js +++ b/src/ol/interaction/DragZoom.js @@ -2,7 +2,7 @@ * @module ol/interaction/DragZoom */ import {inherits} from '../index.js'; -import _ol_easing_ from '../easing.js'; +import {easeOut} from '../easing.js'; import _ol_events_condition_ from '../events/condition.js'; import {createOrUpdateFromCoordinates, getBottomLeft, getCenter, getTopRight, scaleFromCenter} from '../extent.js'; import _ol_interaction_DragBox_ from '../interaction/DragBox.js'; @@ -82,7 +82,7 @@ _ol_interaction_DragZoom_.prototype.onBoxEnd = function() { resolution: resolution, center: center, duration: this.duration_, - easing: _ol_easing_.easeOut + easing: easeOut }); }; diff --git a/src/ol/interaction/Interaction.js b/src/ol/interaction/Interaction.js index de1597544b..b592ca21ae 100644 --- a/src/ol/interaction/Interaction.js +++ b/src/ol/interaction/Interaction.js @@ -5,7 +5,7 @@ import {inherits} from '../index.js'; import _ol_Object_ from '../Object.js'; -import _ol_easing_ from '../easing.js'; +import {easeOut, linear} from '../easing.js'; import _ol_interaction_Property_ from '../interaction/Property.js'; import _ol_math_ from '../math.js'; @@ -106,7 +106,7 @@ _ol_interaction_Interaction_.pan = function(view, delta, opt_duration) { if (opt_duration) { view.animate({ duration: opt_duration, - easing: _ol_easing_.linear, + easing: linear, center: center }); } else { @@ -144,7 +144,7 @@ _ol_interaction_Interaction_.rotateWithoutConstraints = function(view, rotation, rotation: rotation, anchor: opt_anchor, duration: opt_duration, - easing: _ol_easing_.easeOut + easing: easeOut }); } else { view.rotate(rotation, opt_anchor); @@ -229,7 +229,7 @@ _ol_interaction_Interaction_.zoomWithoutConstraints = function(view, resolution, resolution: resolution, anchor: opt_anchor, duration: opt_duration, - easing: _ol_easing_.easeOut + easing: easeOut }); } else { if (opt_anchor) { diff --git a/src/ol/interaction/MouseWheelZoom.js b/src/ol/interaction/MouseWheelZoom.js index 18d93663cc..6303bff5e8 100644 --- a/src/ol/interaction/MouseWheelZoom.js +++ b/src/ol/interaction/MouseWheelZoom.js @@ -3,7 +3,7 @@ */ import {inherits} from '../index.js'; import _ol_ViewHint_ from '../ViewHint.js'; -import _ol_easing_ from '../easing.js'; +import {easeOut} from '../easing.js'; import _ol_events_EventType_ from '../events/EventType.js'; import _ol_has_ from '../has.js'; import _ol_interaction_Interaction_ from '../interaction/Interaction.js'; @@ -204,7 +204,7 @@ _ol_interaction_MouseWheelZoom_.handleEvent = function(mapBrowserEvent) { if (rebound === 0 && this.constrainResolution_) { view.animate({ resolution: view.constrainResolution(resolution, delta > 0 ? -1 : 1), - easing: _ol_easing_.easeOut, + easing: easeOut, anchor: this.lastAnchor_, duration: this.duration_ }); @@ -213,14 +213,14 @@ _ol_interaction_MouseWheelZoom_.handleEvent = function(mapBrowserEvent) { if (rebound > 0) { view.animate({ resolution: minResolution, - easing: _ol_easing_.easeOut, + easing: easeOut, anchor: this.lastAnchor_, duration: 500 }); } else if (rebound < 0) { view.animate({ resolution: maxResolution, - easing: _ol_easing_.easeOut, + easing: easeOut, anchor: this.lastAnchor_, duration: 500 });