Usage example
var myPositionMarker = L.marker([48.864716, 2.294694]).addTo(map);
myPositionMarker.on("click", function() {
var pos = map.latLngToLayerPoint(myPositionMarker.getLatLng());
pos.y -= 25;
var fx = new L.PosAnimation();
fx.once('end',function() {
pos.y += 25;
fx.run(myPositionMarker._icon, pos, 0.8);
});
fx.run(myPositionMarker._icon, pos, 0.3);
});
Constructor
Constructor | Description |
---|---|
L.PosAnimation() | Creates a PosAnimation object.创建PosAnimation对象。 |
Events
Event | Data | Description |
---|---|---|
start | Event | Fired when the animation starts 动画开始时激发 |
step | Event | Fired continuously during the animation. 在动画期间连续激发。 |
end | Event | Fired when the animation ends. 动画结束时激发。 |
Methods
Method | Returns | Description |
---|---|---|
run(<HTMLElement> el, <Point> newPos, <Number> duration?, <Number> easeLinearity?) |
| 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, 0.5 by default).将给定元素的动画运行到新位置,可以选择以秒为单位设置持续时间(默认值为0.25)并放宽线性因子(三次贝塞尔曲线的第三个参数,默认值为0.5)。 |
stop() |
| Stops the animation (if currently running). 停止动画(如果当前正在运行)。 |
▶ Methods inherited from Evented
从Evented继承的方法
Method | Returns | Description |
---|---|---|
on(<String> type, <Function> fn, <Object> context?) | this | Adds a listener function (fn ) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick' ).向对象的特定事件类型添加侦听器函数(fn)。您可以选择指定侦听器的上下文(this关键字将指向的对象)。您还可以传递几个空格分隔的类型(例如“click dblclick”)。 |
on(<Object> eventMap) | this | Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} 添加一组类型/侦听器对,例如{click:onClick,mousemove:onMouseMove} |
off(<String> type, <Function> fn?, <Object> context?) | this | Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on , you must pass the same context to off in order to remove the listener.删除以前添加的侦听器函数。如果没有指定函数,它将从对象中删除该特定事件的所有侦听器。请注意,如果您将自定义上下文传递给on,则必须将相同的上下文传递给off才能删除侦听器。 |
off(<Object> eventMap) | this | Removes a set of type/listener pairs. 删除一组类型/侦听器对。 |
off() | this | Removes all listeners to all events on the object. This includes implicitly attached events. 删除对象上所有事件的所有侦听器。这包括隐式附加的事件。 |
fire(<String> type, <Object> data?, <Boolean> propagate?) | this | Fires an event of the specified type. You can optionally provide a data object — the first argument of the listener function will contain its properties. The event can optionally be propagated to event parents. 激发指定类型的事件。您可以选择提供一个数据对象-侦听器函数的第一个参数将包含其属性。可以选择将事件传播到事件父级。 |
listens(<String> type, <Boolean> propagate?) | Boolean | Returns true if a particular event type has any listeners attached to it. The verification can optionally be propagated, it will return true if parents have the listener attached to it.如果特定事件类型附加了任何侦听器,则返回true。可以选择传播验证,如果父级附加了侦听器,验证将返回true。 |
once(…) | this | Behaves as on(…) , except the listener will only get fired once and then removed.表现为on(…),但监听器只会被解雇一次,然后被移除。 |
addEventParent(<Evented> obj) | this | Adds an event parent – an Evented that will receive propagated events添加事件父级-将接收传播事件的Evented |
removeEventParent(<Evented> obj) | this | Removes an event parent, so it will stop receiving propagated events 删除事件父级,因此它将停止接收传播的事件 |
addEventListener(…) | this | Alias to on(…) |
removeEventListener(…) | this | Alias to off(…) |
clearAllEventListeners(…) | this | Alias to off() |
addOneTimeEventListener(…) | this | Alias to once(…) |
fireEvent(…) | this | Alias to fire(…) |
hasEventListeners(…) | Boolean | Alias to listens(…) |