Sha256: 747d1307247a9a6a2749930218b4d80dc7044a2d27a4aa5d221ae6f6d16b31b9

Contents?: true

Size: 1.48 KB

Versions: 10

Compression:

Stored size: 1.48 KB

Contents

/*
 * L.PosAnimation fallback implementation that powers Leaflet pan animations
 * in browsers that don't support CSS3 Transitions.
 */

L.PosAnimation = L.DomUtil.TRANSITION ? L.PosAnimation : L.PosAnimation.extend({

	run: function (el, newPos, duration, easeLinearity) { // (HTMLElement, Point[, Number, Number])
		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 = L.DomUtil.getPosition(el);
		this._offset = newPos.subtract(this._startPos);
		this._startTime = +new Date();

		this.fire('start');

		this._animate();
	},

	stop: function () {
		if (!this._inProgress) { return; }

		this._step();
		this._complete();
	},

	_animate: function () {
		// animation loop
		this._animId = L.Util.requestAnimFrame(this._animate, this);
		this._step();
	},

	_step: function () {
		var elapsed = (+new Date()) - this._startTime,
		    duration = this._duration * 1000;

		if (elapsed < duration) {
			this._runFrame(this._easeOut(elapsed / duration));
		} else {
			this._runFrame(1);
			this._complete();
		}
	},

	_runFrame: function (progress) {
		var pos = this._startPos.add(this._offset.multiplyBy(progress));
		L.DomUtil.setPosition(this._el, pos);

		this.fire('step');
	},

	_complete: function () {
		L.Util.cancelAnimFrame(this._animId);

		this._inProgress = false;
		this.fire('end');
	},

	_easeOut: function (t) {
		return 1 - Math.pow(1 - t, this._easeOutPower);
	}
});

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
leaflet-js-0.7.9 vendor/assets/Leaflet/src/dom/PosAnimation.Timer.js
leaflet-js-0.7.8 vendor/assets/Leaflet/src/dom/PosAnimation.Timer.js
leaflet-js-0.7.7 vendor/assets/Leaflet/src/dom/PosAnimation.Timer.js
leaflet-js-0.8.dev2 lib/leaflet/src/dom/PosAnimation.Timer.js
leaflet-js-0.7.0.4 lib/leaflet/src/dom/PosAnimation.Timer.js
leaflet-js-0.7.0.3 lib/leaflet/src/dom/PosAnimation.Timer.js
leaflet-js-0.7.0.2 lib/leaflet/src/dom/PosAnimation.Timer.js
leaflet-js-0.7.0.1 lib/leaflet/src/dom/PosAnimation.Timer.js
leaflet-js-0.7.0 lib/leaflet/src/dom/PosAnimation.Timer.js
leaflet-js-0.6.beta4 lib/leaflet/src/dom/PosAnimation.Timer.js