Leaflet Map PosAnimation—内部用于平移动画利用现代浏览器的CSS3转换和IE6-9的定时器回退

Leaflet Map PosAnimation—内部用于平移动画利用现代浏览器的CSS3转换和IE6-9的定时器回退

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

ConstructorDescription
L.PosAnimation()Creates a PosAnimation object.
创建PosAnimation对象。

Events

EventDataDescription
startEventFired when the animation starts
动画开始时激发
stepEventFired continuously during the animation.
在动画期间连续激发。
endEventFired when the animation ends.
动画结束时激发。

Methods

MethodReturnsDescription
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 curve0.5 by default).
将给定元素的动画运行到新位置,可以选择以秒为单位设置持续时间(默认值为0.25)并放宽线性因子(三次贝塞尔曲线的第三个参数,默认值为0.5)。
stop()Stops the animation (if currently running).
停止动画(如果当前正在运行)。

▶ Methods inherited from Evented

从Evented继承的方法

MethodReturnsDescription
on(<String> type, <Function>
 fn, <Object> context?)
thisAdds 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)thisAdds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
添加一组类型/侦听器对,例如{click:onClick,mousemove:onMouseMove}
off(<String> type, <Function>
 fn?, <Object> context?)
thisRemoves 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)thisRemoves a set of type/listener pairs.
删除一组类型/侦听器对。
off()thisRemoves all listeners to all events on the object. This includes implicitly attached events.
删除对象上所有事件的所有侦听器。这包括隐式附加的事件。
fire(<String> type, <Object> 
data?, <Boolean> propagate?)
thisFires 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?)
BooleanReturns 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()thisBehaves as on(…), except the listener will only get fired once and then removed.
表现为on(…),但监听器只会被解雇一次,然后被移除。
addEventParent(<Eventedobj)thisAdds an event parent – an Evented that will receive propagated events
添加事件父级-将接收传播事件的Evented
removeEventParent(<Eventedobj)thisRemoves an event parent, so it will stop receiving propagated events
删除事件父级,因此它将停止接收传播的事件
addEventListener()thisAlias to on(…)
removeEventListener()thisAlias to off(…)
clearAllEventListeners()thisAlias to off()
addOneTimeEventListener()thisAlias to once(…)
fireEvent()thisAlias to fire(…)
hasEventListeners()BooleanAlias to listens(…)
0 0 投票数
文章评分
订阅评论
提醒
0 评论
最旧
最新 最多投票
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x