Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add source to movestart, move, moveend, zoomstart, zoom and zoomend events #6929

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/control/Control.Zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ export var Zoom = Control.extend({

_zoomIn: function (e) {
if (!this._disabled && this._map._zoom < this._map.getMaxZoom()) {
this._map.zoomIn(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));
this._map.zoomIn(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1), 'user.zoomin');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! And thanks for your fix!

I'm not sure if that's because of incompatible Leaflet versions or something, but zoomIn and zoomOut both take 3 parameters now, so in order to get the correct source I had to add undefined as the second parameter in those calls (otherwise I would get imperative).

}
},

_zoomOut: function (e) {
if (!this._disabled && this._map._zoom > this._map.getMinZoom()) {
this._map.zoomOut(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));
this._map.zoomOut(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1), 'user.zoomout');
}
},

Expand Down
11 changes: 6 additions & 5 deletions src/dom/PosAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import * as DomUtil from '../dom/DomUtil';

export var PosAnimation = Evented.extend({

// @method run(el: HTMLElement, newPos: Point, duration?: Number, easeLinearity?: Number)
// @method run(el: HTMLElement, newPos: Point, duration?: Number, easeLinearity?: Number, source?: String)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No mention in description

// 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) {
run: function (el, newPos, duration, easeLinearity, source) {
this.stop();

this._el = el;
Expand All @@ -38,10 +38,11 @@ export var PosAnimation = Evented.extend({
this._startPos = DomUtil.getPosition(el);
this._offset = newPos.subtract(this._startPos);
this._startTime = +new Date();
this._source = source || 'imperative';

// @event start: Event
// Fired when the animation starts
this.fire('start');
this.fire('start', {source: this._source});

this._animate();
},
Expand Down Expand Up @@ -82,7 +83,7 @@ export var PosAnimation = Evented.extend({

// @event step: Event
// Fired continuously during the animation.
this.fire('step');
this.fire('step', {source: this._source});
},

_complete: function () {
Expand All @@ -91,7 +92,7 @@ export var PosAnimation = Evented.extend({
this._inProgress = false;
// @event end: Event
// Fired when the animation ends.
this.fire('end');
this.fire('end', {source: this._source});
},

_easeOut: function (t) {
Expand Down
Loading