summaryrefslogtreecommitdiffstats
path: root/debian/missing-sources/leaflet.js/dom/PosAnimation.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:24:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:24:15 +0000
commitf7fa67dcc49b0b50ae2323b13facac69f2b5e495 (patch)
treeb57cfa4095263521138ba8d3b372d91d99487a3e /debian/missing-sources/leaflet.js/dom/PosAnimation.js
parentAdding upstream version 1.1.0. (diff)
downloadicingaweb2-module-map-debian/1.1.0-4.tar.xz
icingaweb2-module-map-debian/1.1.0-4.zip
Adding debian version 1.1.0-4.debian/1.1.0-4debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/missing-sources/leaflet.js/dom/PosAnimation.js')
-rw-r--r--debian/missing-sources/leaflet.js/dom/PosAnimation.js100
1 files changed, 100 insertions, 0 deletions
diff --git a/debian/missing-sources/leaflet.js/dom/PosAnimation.js b/debian/missing-sources/leaflet.js/dom/PosAnimation.js
new file mode 100644
index 0000000..05290c1
--- /dev/null
+++ b/debian/missing-sources/leaflet.js/dom/PosAnimation.js
@@ -0,0 +1,100 @@
+import * as Util from '../core/Util';
+import {Evented} from '../core/Events';
+import * as DomUtil from '../dom/DomUtil';
+
+
+/*
+ * @class PosAnimation
+ * @aka L.PosAnimation
+ * @inherits Evented
+ * Used internally for panning animations, utilizing CSS3 Transitions for modern browsers and a timer fallback for IE6-9.
+ *
+ * @example
+ * ```js
+ * var fx = new L.PosAnimation();
+ * fx.run(el, [300, 500], 0.5);
+ * ```
+ *
+ * @constructor L.PosAnimation()
+ * Creates a `PosAnimation` object.
+ *
+ */
+
+export var PosAnimation = Evented.extend({
+
+ // @method run(el: HTMLElement, newPos: Point, duration?: Number, easeLinearity?: Number)
+ // Run an animation of a given element to a new position, optionally setting
+ // duration in seconds (`0.25` by default) and easing linearity factor (3rd
+ // argument of the [cubic bezier curve](http://cubic-bezier.com/#0,0,.5,1),
+ // `0.5` by default).
+ run: function (el, newPos, duration, easeLinearity) {
+ this.stop();
+
+ this._el = el;
+ this._inProgress = true;
+ this._duration = duration || 0.25;
+ this._easeOutPower = 1 / Math.max(easeLinearity || 0.5, 0.2);
+
+ this._startPos = DomUtil.getPosition(el);
+ this._offset = newPos.subtract(this._startPos);
+ this._startTime = +new Date();
+
+ // @event start: Event
+ // Fired when the animation starts
+ this.fire('start');
+
+ this._animate();
+ },
+
+ // @method stop()
+ // Stops the animation (if currently running).
+ stop: function () {
+ if (!this._inProgress) { return; }
+
+ this._step(true);
+ this._complete();
+ },
+
+ _animate: function () {
+ // animation loop
+ this._animId = Util.requestAnimFrame(this._animate, this);
+ this._step();
+ },
+
+ _step: function (round) {
+ var elapsed = (+new Date()) - this._startTime,
+ duration = this._duration * 1000;
+
+ if (elapsed < duration) {
+ this._runFrame(this._easeOut(elapsed / duration), round);
+ } else {
+ this._runFrame(1);
+ this._complete();
+ }
+ },
+
+ _runFrame: function (progress, round) {
+ var pos = this._startPos.add(this._offset.multiplyBy(progress));
+ if (round) {
+ pos._round();
+ }
+ DomUtil.setPosition(this._el, pos);
+
+ // @event step: Event
+ // Fired continuously during the animation.
+ this.fire('step');
+ },
+
+ _complete: function () {
+ Util.cancelAnimFrame(this._animId);
+
+ this._inProgress = false;
+ // @event end: Event
+ // Fired when the animation ends.
+ this.fire('end');
+ },
+
+ _easeOut: function (t) {
+ return 1 - Math.pow(1 - t, this._easeOutPower);
+ }
+});