2 * L.Transition native implementation that powers Leaflet animation
3 * in browsers that support CSS3 Transitions
6 L
.Transition
= L
.Transition
.extend({
8 var transition
= L
.DomUtil
.TRANSITION
,
9 transitionEnd
= (transition
== 'webkitTransition' || transition
== 'OTransition' ?
10 transition
+ 'End' : 'transitionend');
15 TRANSITION
: transition
,
16 PROPERTY
: transition
+ 'Property',
17 DURATION
: transition
+ 'Duration',
18 EASING
: transition
+ 'TimingFunction',
21 // transition-property value to use with each particular custom property
22 CUSTOM_PROPS_PROPERTIES
: {
23 position
: L
.Browser
.webkit
? L
.DomUtil
.TRANSFORM
: 'top, left'
32 initialize: function(/*HTMLElement*/ el
, /*Object*/ options
) {
34 L
.Util
.setOptions(this, options
);
36 L
.DomEvent
.addListener(el
, L
.Transition
.END
, this._onTransitionEnd
, this);
37 this._onFakeStep
= L
.Util
.bind(this._onFakeStep
, this);
40 run: function(/*Object*/ props
) {
43 customProp
= L
.Transition
.CUSTOM_PROPS_PROPERTIES
;
46 if (props
.hasOwnProperty(prop
)) {
47 prop
= customProp
[prop
] ? customProp
[prop
] : prop
;
48 prop
= prop
.replace(/([A-Z])/g, function(w
) { return '-' + w
.toLowerCase(); });
53 this._el
.style
[L
.Transition
.DURATION
] = this.options
.duration
+ 's';
54 this._el
.style
[L
.Transition
.EASING
] = this.options
.easing
;
55 this._el
.style
[L
.Transition
.PROPERTY
] = propsList
.join(', ');
58 if (props
.hasOwnProperty(prop
)) {
59 this._setProperty(prop
, props
[prop
]);
63 this._inProgress
= true;
67 if (L
.Transition
.NATIVE
) {
68 this._timer
= setInterval(this._onFakeStep
, this.options
.fakeStepInterval
);
70 this._onTransitionEnd();
74 _onFakeStep: function() {
78 _onTransitionEnd: function() {
79 if (this._inProgress
) {
80 this._inProgress
= false;
81 clearInterval(this._timer
);
83 this._el
.style
[L
.Transition
.PROPERTY
] = 'none';