diff --git a/dist/leaflet.motion.js b/dist/leaflet.motion.js index ab682fc..6a7ba35 100644 --- a/dist/leaflet.motion.js +++ b/dist/leaflet.motion.js @@ -1,6 +1,6 @@ /*! * - * leaflet.motion - v0.1.7 (https://github.com/Igor-Vladyka/leaflet.motion#readme) + * leaflet.motion - v0.1.8 (https://github.com/Igor-Vladyka/leaflet.motion#readme) * Animation plugin for Leaflet.js * * MIT (http://www.opensource.org/licenses/mit-license.php) @@ -106,6 +106,17 @@ eval("/**\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tA /***/ }), +/***/ "./src/layer/leaflet.motion.polygon.js": +/*!*********************************************!*\ + !*** ./src/layer/leaflet.motion.polygon.js ***! + \*********************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("/**\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Igor Vladyka (https://github.com/Igor-Vladyka/leaflet.motion)\n**/\n\nL.Motion.Polygon = L.Polygon.extend(L.Motion.Animate);\n\nL.motion.polygon = function(latlngs, options, motionOptions, markerOptions){\n return new L.Motion.Polygon(latlngs, options, motionOptions, markerOptions);\n};\n\n\n//# sourceURL=webpack:///./src/layer/leaflet.motion.polygon.js?"); + +/***/ }), + /***/ "./src/layer/leaflet.motion.polyline.js": /*!**********************************************!*\ !*** ./src/layer/leaflet.motion.polyline.js ***! @@ -162,13 +173,13 @@ eval("/**\r\n\tMIT License http://www.opensource.org/licenses/mit-license.php\r\ /***/ }), /***/ 0: -/*!***************************************************************************************************************************************************************************************************************!*\ - !*** multi ./src/leaflet.motion.js ./src/leaflet.motion.utils.js ./src/leaflet.motion.easing.js ./src/layer/leaflet.motion.polyline.js ./src/layer/leaflet.motion.group.js ./src/layer/leaflet.motion.seq.js ***! - \***************************************************************************************************************************************************************************************************************/ +/*!*****************************************************************************************************************************************************************************************************************************************************!*\ + !*** multi ./src/leaflet.motion.js ./src/leaflet.motion.utils.js ./src/leaflet.motion.easing.js ./src/layer/leaflet.motion.polyline.js ./src/layer/leaflet.motion.polygon.js ./src/layer/leaflet.motion.group.js ./src/layer/leaflet.motion.seq.js ***! + \*****************************************************************************************************************************************************************************************************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("__webpack_require__(/*! ./src/leaflet.motion.js */\"./src/leaflet.motion.js\");\n__webpack_require__(/*! ./src/leaflet.motion.utils.js */\"./src/leaflet.motion.utils.js\");\n__webpack_require__(/*! ./src/leaflet.motion.easing.js */\"./src/leaflet.motion.easing.js\");\n__webpack_require__(/*! ./src/layer/leaflet.motion.polyline.js */\"./src/layer/leaflet.motion.polyline.js\");\n__webpack_require__(/*! ./src/layer/leaflet.motion.group.js */\"./src/layer/leaflet.motion.group.js\");\nmodule.exports = __webpack_require__(/*! ./src/layer/leaflet.motion.seq.js */\"./src/layer/leaflet.motion.seq.js\");\n\n\n//# sourceURL=webpack:///multi_./src/leaflet.motion.js_./src/leaflet.motion.utils.js_./src/leaflet.motion.easing.js_./src/layer/leaflet.motion.polyline.js_./src/layer/leaflet.motion.group.js_./src/layer/leaflet.motion.seq.js?"); +eval("__webpack_require__(/*! ./src/leaflet.motion.js */\"./src/leaflet.motion.js\");\n__webpack_require__(/*! ./src/leaflet.motion.utils.js */\"./src/leaflet.motion.utils.js\");\n__webpack_require__(/*! ./src/leaflet.motion.easing.js */\"./src/leaflet.motion.easing.js\");\n__webpack_require__(/*! ./src/layer/leaflet.motion.polyline.js */\"./src/layer/leaflet.motion.polyline.js\");\n__webpack_require__(/*! ./src/layer/leaflet.motion.polygon.js */\"./src/layer/leaflet.motion.polygon.js\");\n__webpack_require__(/*! ./src/layer/leaflet.motion.group.js */\"./src/layer/leaflet.motion.group.js\");\nmodule.exports = __webpack_require__(/*! ./src/layer/leaflet.motion.seq.js */\"./src/layer/leaflet.motion.seq.js\");\n\n\n//# sourceURL=webpack:///multi_./src/leaflet.motion.js_./src/leaflet.motion.utils.js_./src/leaflet.motion.easing.js_./src/layer/leaflet.motion.polyline.js_./src/layer/leaflet.motion.polygon.js_./src/layer/leaflet.motion.group.js_./src/layer/leaflet.motion.seq.js?"); /***/ }) diff --git a/dist/leaflet.motion.min.js b/dist/leaflet.motion.min.js index 04086b3..baa0082 100644 --- a/dist/leaflet.motion.min.js +++ b/dist/leaflet.motion.min.js @@ -1,9 +1,9 @@ /*! * - * leaflet.motion - v0.1.7 (https://github.com/Igor-Vladyka/leaflet.motion#readme) + * leaflet.motion - v0.1.8 (https://github.com/Igor-Vladyka/leaflet.motion#readme) * Animation plugin for Leaflet.js * * MIT (http://www.opensource.org/licenses/mit-license.php) * (c) 2020 Igor Vladyka (https://github.com/Igor-Vladyka/) * - */!function(t){var n={};function i(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=t,i.c=n,i.d=function(t,n,e){i.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,n){if(1&n&&(t=i(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(i.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)i.d(e,o,function(n){return t[n]}.bind(null,o));return e},i.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(n,"a",n),n},i.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},i.p="",i(i.s=0)}([function(t,n,i){i(1),i(2),i(3),i(4),i(5),t.exports=i(6)},function(t,n){L.Motion=L.Motion||{Event:{Started:"motion-started",Paused:"motion-paused",Resumed:"motion-resumed",Section:"motion-section",Ended:"motion-ended"}},L.motion=L.motion||{},L.Motion.Animate={options:{pane:"polymotionPane",attribution:"Leaflet.Motion © "+(new Date).getFullYear()+" Igor Vladyka"},motionOptions:{auto:!1,easing:function(t){return t},speed:0,duration:0},markerOptions:void 0,initialize:function(t,n,i,e){L.Util.setOptions(this,n),this.motionOptions=L.Util.extend({},this.motionOptions,i||{}),this.markerOptions=L.Util.extend({},e||{}),this._bounds=L.latLngBounds(),this._linePoints=this._convertLatLngs(t),L.Motion.Utils.isFlat(this._linePoints)||(this._linePoints=this._linePoints[0]),this._initializeMarker(),this._latlngs=[],L.Util.stamp(this)},addLatLng:function(t,n){return t=L.Motion.Utils.toLatLng(t),this._linePoints.push(t),this._latlngs.length&&this._latlngs.push(t),this},beforeAdd:function(t){t.getPane(this.options.pane)||(t.createPane(this.options.pane).style.zIndex=599),this._renderer=t.getRenderer(this)},onAdd:function(t){if(this._renderer._initPath(this),this._reset(),this._renderer._addPath(this),this.__marker&&this.markerOptions.showMarker&&this.__marker.addTo(t),this.__marker._icon&&this.__marker._icon.children.length){var n=this.__marker._icon.children[0].getAttribute("motion-base");n&&(this.__marker._icon.children[0].style.transform="rotate("+n+"deg)")}return this.motionOptions.auto&&this.motionStart(),this},onRemove:function(t){this.motionStop(),this.__marker&&t.removeLayer(this.__marker),this._renderer._removePath(this)},_motion:function(t){var n=(new Date).getTime()-t,i=1;if(this.motionOptions.duration&&(i=n/this.motionOptions.duration),i<1){i=this.motionOptions.easing(i,n,0,1,this.motionOptions.duration);var e=L.Motion.Utils.interpolateOnLine(this._map,this._linePoints,i);L.Polyline.prototype.addLatLng.call(this,e.latLng),this._drawMarker(e.latLng),this.__ellapsedTime=n,this.animation=L.Util.requestAnimFrame((function(){this._motion(t)}),this)}else this.motionStop(!0)},_drawMarker:function(t){var n=this.getMarker();if(n){var i=n.getLatLng(),e=this._linePoints[0];if(i.lat===e.lat&&i.lng===e.lng)n.addTo(this._map),n.addEventParent(this);else if(n._icon&&n._icon.children.length){var o=n._icon.children[0].getAttribute("motion-base");if(o){var r=0;o&&!isNaN(+o)&&(r=+o),n._icon.children[0].style.transform="rotate(-"+Math.round(L.Motion.Utils.getAngle(i,t)+r)+"deg)"}}n.setLatLng(t)}},_removeMarker:function(t){this.markerOptions&&this.__marker&&(t&&!this.markerOptions.removeOnEnd||this._map.removeLayer(this.__marker))},_initializeMarker:function(){this.markerOptions&&(this.__marker=L.marker(this._linePoints[0],this.markerOptions))},motionStart:function(){return this._map&&!this.animation&&(this.motionOptions.duration||(this.motionOptions.speed?this.motionOptions.duration=L.Motion.Utils.getDuration(this._linePoints,this.motionOptions.speed):this.motionOptions.duration=0),this.setLatLngs([]),this._motion((new Date).getTime()),this.fire(L.Motion.Event.Started,{layer:this},!1)),this},motionStop:function(t){return this.motionPause(),this.setLatLngs(this._linePoints),this.__ellapsedTime=null,this._removeMarker(t),this.fire(L.Motion.Event.Ended,{layer:this},!1),this},motionPause:function(){return this.animation&&(L.Util.cancelAnimFrame(this.animation),this.animation=null,this.fire(L.Motion.Event.Paused,{layer:this},!1)),this},motionResume:function(){return!this.animation&&this.__ellapsedTime&&(this.motionOptions.duration||(this.motionOptions.speed?this.motionOptions.duration=L.Motion.Utils.getDuration(this._linePoints,this.motionOptions.speed):this.motionOptions.duration=0),this._motion((new Date).getTime()-this.__ellapsedTime),this.fire(L.Motion.Event.Resumed,{layer:this},!1)),this},motionToggle:function(){return this.animation?this.__ellapsedTime&&this.motionPause():this.__ellapsedTime?this.motionResume():this.motionStart(),this},motionDuration:function(t){return this.motionOptions.duration=t||0,this},motionSpeed:function(t){return this.motionOptions.speed=t||0,this},getMarker:function(){return this.__marker},getMarkers:function(){return[this.getMarker()]}}},function(t,n){L.Motion.Utils={interpolateOnLine:function(t,n,i){var e=(n=n instanceof L.Polyline?n.getLatLngs():n).length;if(e<2)return null;if(0===(i=Math.max(Math.min(i,1),0)))return{latLng:n[0]instanceof L.LatLng?n[0]:L.latLng(n[0]),predecessor:-1};if(1==i)return{latLng:n[n.length-1]instanceof L.LatLng?n[n.length-1]:L.latLng(n[n.length-1]),predecessor:n.length-2};var o=t.getMaxZoom();o===1/0&&(o=t.getZoom());for(var r=[],a=0,s=0;s0&&(a+=r[s-1].distanceTo(r[s]));var u=a*i,h=0,l=0;for(s=0;lo?n[o].motionStart():this.fire(L.Motion.Event.Ended,{layer:this},!1)},__putActiveLayer__:function(t){this._activeLayer=t.layer,this.fire(L.Motion.Event.Section,{layer:this._activeLayer},!1)}}),L.motion.seq=function(t,n){return new L.Motion.Seq(t,n)}}]); \ No newline at end of file + */!function(t){var n={};function i(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=t,i.c=n,i.d=function(t,n,e){i.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,n){if(1&n&&(t=i(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(i.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)i.d(e,o,function(n){return t[n]}.bind(null,o));return e},i.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(n,"a",n),n},i.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},i.p="",i(i.s=0)}([function(t,n,i){i(1),i(2),i(3),i(4),i(5),i(6),t.exports=i(7)},function(t,n){L.Motion=L.Motion||{Event:{Started:"motion-started",Paused:"motion-paused",Resumed:"motion-resumed",Section:"motion-section",Ended:"motion-ended"}},L.motion=L.motion||{},L.Motion.Animate={options:{pane:"polymotionPane",attribution:"Leaflet.Motion © "+(new Date).getFullYear()+" Igor Vladyka"},motionOptions:{auto:!1,easing:function(t){return t},speed:0,duration:0},markerOptions:void 0,initialize:function(t,n,i,e){L.Util.setOptions(this,n),this.motionOptions=L.Util.extend({},this.motionOptions,i||{}),this.markerOptions=L.Util.extend({},e||{}),this._bounds=L.latLngBounds(),this._linePoints=this._convertLatLngs(t),L.Motion.Utils.isFlat(this._linePoints)||(this._linePoints=this._linePoints[0]),this._initializeMarker(),this._latlngs=[],L.Util.stamp(this)},addLatLng:function(t,n){return t=L.Motion.Utils.toLatLng(t),this._linePoints.push(t),this._latlngs.length&&this._latlngs.push(t),this},beforeAdd:function(t){t.getPane(this.options.pane)||(t.createPane(this.options.pane).style.zIndex=599),this._renderer=t.getRenderer(this)},onAdd:function(t){if(this._renderer._initPath(this),this._reset(),this._renderer._addPath(this),this.__marker&&this.markerOptions.showMarker&&this.__marker.addTo(t),this.__marker._icon&&this.__marker._icon.children.length){var n=this.__marker._icon.children[0].getAttribute("motion-base");n&&(this.__marker._icon.children[0].style.transform="rotate("+n+"deg)")}return this.motionOptions.auto&&this.motionStart(),this},onRemove:function(t){this.motionStop(),this.__marker&&t.removeLayer(this.__marker),this._renderer._removePath(this)},_motion:function(t){var n=(new Date).getTime()-t,i=1;if(this.motionOptions.duration&&(i=n/this.motionOptions.duration),i<1){i=this.motionOptions.easing(i,n,0,1,this.motionOptions.duration);var e=L.Motion.Utils.interpolateOnLine(this._map,this._linePoints,i);L.Polyline.prototype.addLatLng.call(this,e.latLng),this._drawMarker(e.latLng),this.__ellapsedTime=n,this.animation=L.Util.requestAnimFrame((function(){this._motion(t)}),this)}else this.motionStop(!0)},_drawMarker:function(t){var n=this.getMarker();if(n){var i=n.getLatLng(),e=this._linePoints[0];if(i.lat===e.lat&&i.lng===e.lng)n.addTo(this._map),n.addEventParent(this);else if(n._icon&&n._icon.children.length){var o=n._icon.children[0].getAttribute("motion-base");if(o){var r=0;o&&!isNaN(+o)&&(r=+o),n._icon.children[0].style.transform="rotate(-"+Math.round(L.Motion.Utils.getAngle(i,t)+r)+"deg)"}}n.setLatLng(t)}},_removeMarker:function(t){this.markerOptions&&this.__marker&&(t&&!this.markerOptions.removeOnEnd||this._map.removeLayer(this.__marker))},_initializeMarker:function(){this.markerOptions&&(this.__marker=L.marker(this._linePoints[0],this.markerOptions))},motionStart:function(){return this._map&&!this.animation&&(this.motionOptions.duration||(this.motionOptions.speed?this.motionOptions.duration=L.Motion.Utils.getDuration(this._linePoints,this.motionOptions.speed):this.motionOptions.duration=0),this.setLatLngs([]),this._motion((new Date).getTime()),this.fire(L.Motion.Event.Started,{layer:this},!1)),this},motionStop:function(t){return this.motionPause(),this.setLatLngs(this._linePoints),this.__ellapsedTime=null,this._removeMarker(t),this.fire(L.Motion.Event.Ended,{layer:this},!1),this},motionPause:function(){return this.animation&&(L.Util.cancelAnimFrame(this.animation),this.animation=null,this.fire(L.Motion.Event.Paused,{layer:this},!1)),this},motionResume:function(){return!this.animation&&this.__ellapsedTime&&(this.motionOptions.duration||(this.motionOptions.speed?this.motionOptions.duration=L.Motion.Utils.getDuration(this._linePoints,this.motionOptions.speed):this.motionOptions.duration=0),this._motion((new Date).getTime()-this.__ellapsedTime),this.fire(L.Motion.Event.Resumed,{layer:this},!1)),this},motionToggle:function(){return this.animation?this.__ellapsedTime&&this.motionPause():this.__ellapsedTime?this.motionResume():this.motionStart(),this},motionDuration:function(t){return this.motionOptions.duration=t||0,this},motionSpeed:function(t){return this.motionOptions.speed=t||0,this},getMarker:function(){return this.__marker},getMarkers:function(){return[this.getMarker()]}}},function(t,n){L.Motion.Utils={interpolateOnLine:function(t,n,i){var e=(n=n instanceof L.Polyline?n.getLatLngs():n).length;if(e<2)return null;if(0===(i=Math.max(Math.min(i,1),0)))return{latLng:n[0]instanceof L.LatLng?n[0]:L.latLng(n[0]),predecessor:-1};if(1==i)return{latLng:n[n.length-1]instanceof L.LatLng?n[n.length-1]:L.latLng(n[n.length-1]),predecessor:n.length-2};var o=t.getMaxZoom();o===1/0&&(o=t.getZoom());for(var r=[],a=0,s=0;s0&&(a+=r[s-1].distanceTo(r[s]));var u=a*i,h=0,l=0;for(s=0;lo?n[o].motionStart():this.fire(L.Motion.Event.Ended,{layer:this},!1)},__putActiveLayer__:function(t){this._activeLayer=t.layer,this.fire(L.Motion.Event.Section,{layer:this._activeLayer},!1)}}),L.motion.seq=function(t,n){return new L.Motion.Seq(t,n)}}]); \ No newline at end of file diff --git a/package.json b/package.json index cfb4470..eb3ab25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "leaflet.motion", - "version": "0.1.7", + "version": "0.1.8", "keywords": [ "leaflet.js", "browser", diff --git a/webpack.config.js b/webpack.config.js index c8e716b..1cf440a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -11,7 +11,7 @@ var pluginFiles = [ './src/leaflet.motion.utils.js', './src/leaflet.motion.easing.js', './src/layer/leaflet.motion.polyline.js', - //'./src/layer/leaflet.motion.polygon.js', + './src/layer/leaflet.motion.polygon.js', './src/layer/leaflet.motion.group.js', './src/layer/leaflet.motion.seq.js' ];