diff --git a/dist/leaflet.motion.js b/dist/leaflet.motion.js index ea610de..7b56859 100644 --- a/dist/leaflet.motion.js +++ b/dist/leaflet.motion.js @@ -1,108 +1,30 @@ /*! * - * leaflet.motion - v0.3.2 (https://github.com/Igor-Vladyka/leaflet.motion#readme) + * leaflet.motion - v0.3.2 (https://github.com/Igor-Vladyka/leaflet.motion#readme) * Animation plugin for Leaflet.js - * + * * MIT (http://www.opensource.org/licenses/mit-license.php) - * (c) 2022 Igor Vladyka (https://github.com/Igor-Vladyka/) - * + * (c) 2025 Igor Vladyka (https://github.com/Igor-Vladyka/) + * */ -/******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 0); -/******/ }) -/************************************************************************/ -/******/ ({ +/* + * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). + * This devtool is neither made for production nor for readable output files. + * It uses "eval()" calls to create a separate source file in the browser devtools. + * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) + * or disable the default devtool with "devtool: false". + * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). + */ +/******/ (() => { // webpackBootstrap +/******/ var __webpack_modules__ = ({ /***/ "./src/layer/leaflet.motion.group.js": /*!*******************************************!*\ !*** ./src/layer/leaflet.motion.group.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.Group = L.FeatureGroup.extend ({\n\t_started: false,\n\t_completed: false,\n\n\toptions: {\n\t\tpane: L.Motion.Animate.options.pane,\n\t\tattribution: L.Motion.Animate.options.attribution,\n\t},\n\n\t/**\n\t\tStarts all motions in current group;\n\t*/\n\tmotionStart: function () {\n\t\tthis.invoke(\"motionStart\");\n\t\tthis._started = true;\n\t\tthis._completed = false;\n\t\tthis.fire(L.Motion.Event.Started, {layer: this}, false);\n\t\treturn this;\n\t},\n\n\t/**\n\t\tStops all motions in current group;\n\t*/\n\tmotionStop: function () {\n\t\tthis.invoke(\"motionStop\");\n\t\tthis._completed = true;\n\t\tthis.fire(L.Motion.Event.Ended, {layer: this}, false);\n\t\treturn this;\n\t},\n\n\t/**\n\t\tPauses all motions in current group;\n\t*/\n\tmotionPause: function () {\n\t\tthis.invoke(\"motionPause\");\n\t\tthis.fire(L.Motion.Event.Paused, {layer: this}, false);\n\t\treturn this;\n\t},\n\n\t/**\n\t\tReset all motions in current group;\n\t*/\n\tmotionResume: function () {\n\t\tthis.invoke(\"motionResume\");\n\t\tthis.fire(L.Motion.Event.Resumed, {layer: this}, false);\n\t\treturn this;\n\t},\n\n\t/**\n\t\tReset all motions in current group;\n\t*/\n\tmotionToggle: function () {\n\t\tthis.invoke(\"motionToggle\");\n\t\treturn this;\n\t},\n\n\t/**\n\t\tReturns markers array from all inner layers without flattering.\n\t*/\n\tgetMarkers: function () {\n\t\treturn this.getLayers().map(function(l) { return l.getMarkers(); });\n\t}\n});\n\nL.motion.group = function(motions, options){\n return new L.Motion.Group(motions, options);\n};\n\n\n//# sourceURL=webpack:///./src/layer/leaflet.motion.group.js?"); +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.Group = L.FeatureGroup.extend ({\n\t_started: false,\n\t_completed: false,\n\n\toptions: {\n\t\tpane: L.Motion.Animate.options.pane,\n\t\tattribution: L.Motion.Animate.options.attribution,\n\t},\n\n\t/**\n\t\tStarts all motions in current group;\n\t*/\n\tmotionStart: function () {\n\t\tthis.invoke(\"motionStart\");\n\t\tthis._started = true;\n\t\tthis._completed = false;\n\t\tthis.fire(L.Motion.Event.Started, {layer: this}, false);\n\t\treturn this;\n\t},\n\n\t/**\n\t\tStops all motions in current group;\n\t*/\n\tmotionStop: function () {\n\t\tthis.invoke(\"motionStop\");\n\t\tthis._completed = true;\n\t\tthis.fire(L.Motion.Event.Ended, {layer: this}, false);\n\t\treturn this;\n\t},\n\n\t/**\n\t\tPauses all motions in current group;\n\t*/\n\tmotionPause: function () {\n\t\tthis.invoke(\"motionPause\");\n\t\tthis.fire(L.Motion.Event.Paused, {layer: this}, false);\n\t\treturn this;\n\t},\n\n\t/**\n\t\tReset all motions in current group;\n\t*/\n\tmotionResume: function () {\n\t\tthis.invoke(\"motionResume\");\n\t\tthis.fire(L.Motion.Event.Resumed, {layer: this}, false);\n\t\treturn this;\n\t},\n\n\t/**\n\t\tReset all motions in current group;\n\t*/\n\tmotionToggle: function () {\n\t\tthis.invoke(\"motionToggle\");\n\t\treturn this;\n\t},\n\n\t/**\n\t\tReturns markers array from all inner layers without flattering.\n\t*/\n\tgetMarkers: function () {\n\t\treturn this.getLayers().map(function(l) { return l.getMarkers(); });\n\t}\n});\n\nL.motion.group = function(motions, options){\n return new L.Motion.Group(motions, options);\n};\n\n\n//# sourceURL=webpack://leaflet.motion/./src/layer/leaflet.motion.group.js?"); /***/ }), @@ -110,10 +32,9 @@ eval("/**\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tA /*!*********************************************!*\ !*** ./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?"); +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://leaflet.motion/./src/layer/leaflet.motion.polygon.js?"); /***/ }), @@ -121,10 +42,9 @@ eval("/**\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tA /*!**********************************************!*\ !*** ./src/layer/leaflet.motion.polyline.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.Polyline = L.Polyline.extend(L.Motion.Animate);\n\nL.motion.polyline = function(latlngs, options, motionOptions, markerOptions){\n return new L.Motion.Polyline(latlngs, options, motionOptions, markerOptions);\n};\n\n\n//# sourceURL=webpack:///./src/layer/leaflet.motion.polyline.js?"); +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.Polyline = L.Polyline.extend(L.Motion.Animate);\n\nL.motion.polyline = function(latlngs, options, motionOptions, markerOptions){\n return new L.Motion.Polyline(latlngs, options, motionOptions, markerOptions);\n};\n\n\n//# sourceURL=webpack://leaflet.motion/./src/layer/leaflet.motion.polyline.js?"); /***/ }), @@ -132,10 +52,9 @@ eval("/**\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tA /*!*****************************************!*\ !*** ./src/layer/leaflet.motion.seq.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.Seq = L.Motion.Group.extend ({\n\t_activeLayer: null,\n\t_started: false,\n\t_completed: false,\n\n\taddLayer: function (l, autostart) {\n\t\tif (autostart === undefined) {\n\t\t\tautostart = true;\n\t\t}\n\t\tthis.__prepareLayer(l);\n\t\tL.Motion.Group.prototype.addLayer.call(this, l);\n\n\t\tif (!this._activeLayer && autostart && this._completed) {\n\t\t\tl.motionStart();\n\t\t}\n\t},\n\n\t/**\n\t\tStart first motion in current group;\n\t*/\n\tmotionStart: function() {\n\t\t// We will start animation only when its not running\n\t\tif (!this._activeLayer) {\n\t\t\tvar layer = this.getFirstLayer();\n\t\t\tif (layer) {\n\t\t\t\tlayer.motionStart();\n\t\t\t\tthis._started = true;\n\t\t\t\tthis._completed = false;\n\t\t\t\tthis.fire(L.Motion.Event.Started, {layer: this}, false);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n\t\tStops all motions in current group;\n\t*/\n\tmotionStop: function(softstop) {\n\t\tif (!softstop) {\n\t\t\tthis.invoke(\"motionStop\");\n\t\t}\n\t\tthis._activeLayer = null;\n\t\tthis._completed = true;\n\t\tthis.fire(L.Motion.Event.Ended, {layer: this}, false);\n\n\t\treturn this;\n\t},\n\n\t/**\n\t\tPause current motion in current group;\n\t*/\n\tmotionPause: function() {\n\t\tif (this._activeLayer) {\n\t\t\tthis._activeLayer.motionPause();\n\t\t\tthis.fire(L.Motion.Event.Paused, {layer: this}, false);\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n\t\tResume last motion in current group;\n\t*/\n\tmotionResume: function() {\n\t\tif (this._activeLayer) {\n\t\t\tthis._activeLayer.motionResume();\n\t\t\tthis.fire(L.Motion.Event.Resumed, {layer: this}, false);\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n\t\tReset all motions in current group;\n\t*/\n\tmotionToggle: function () {\n\t\tif (this._activeLayer) {\n\t\t\tthis.motionPause();\n\t\t} else {\n\t\t\tthis.motionResume();\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tgetFirstLayer: function() {\n\t\tvar allLayers = this.getLayers();\n\t\treturn allLayers.length ? allLayers[0] : null;\n\t},\n\n\t/**\n\t\tInitialise a layer so it's ready to be part of this motion sequence\n\t*/\n\t__prepareLayer: function (l) {\n\t\tif (l.setLatLngs) {\n\t\t\tl.setLatLngs([]);\n\t\t}\n\n\t\t// When a layer finishes have it remove itself and call motionStart() on the next layer\n\t\tl.off(L.Motion.Event.Ended, this.__clearActiveLayer__, this);\n\t\tl.on(L.Motion.Event.Ended, this.__clearActiveLayer__, this);\n\n\t\t// When a layer is started (by the last one ending) set it as the active layer\n\t\tl.off(L.Motion.Event.Started, this.__putActiveLayer__, this);\n\t\tl.on(L.Motion.Event.Started, this.__putActiveLayer__, this);\n\t},\n\n\t/**\n\t\tCalled by a layer (e.g. one of the sequence events) when it finishes. Is responsible for\n\t\tcleaning up after itself and starting the next layer.\n\t */\n\t__clearActiveLayer__: function (e) {\n\t\tthis._activeLayer = null;\n\t\tvar layers = this.getLayers();\n\t\tvar currentId = e.layer._leaflet_id;\n\t\tvar currentObject = layers.filter(function(f){ return f._leaflet_id == currentId })[0];\n\t\tvar nextIndex = layers.indexOf(currentObject) + 1;\n\t\tif (layers.length > nextIndex) {\n\t\t\tlayers[nextIndex].motionStart();\n\t\t} else {\n\t\t\t//this.fire(L.Motion.Event.Ended, {layer: this}, false);\n\t\t\tthis.motionStop(true);\n\t\t}\n\t},\n\n\t/**\n\t\tCalled by a layer when it's started, sets itself as the active layer on the sequence\n\t\tgroup and trigger any other events which need triggering.\n\t */\n\t__putActiveLayer__: function (e) {\n\t\tthis._activeLayer = e.layer;\n\t\tthis.fire(L.Motion.Event.Section, {layer: this._activeLayer}, false);\n\t}\n});\n\nL.motion.seq = function(motion, options){\n return new L.Motion.Seq(motion, options);\n};\n\n\n//# sourceURL=webpack:///./src/layer/leaflet.motion.seq.js?"); +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.Seq = L.Motion.Group.extend ({\n\t_activeLayer: null,\n\t_started: false,\n\t_completed: false,\n\n\taddLayer: function (l, autostart) {\n\t\tif (autostart === undefined) {\n\t\t\tautostart = true;\n\t\t}\n\t\tthis.__prepareLayer(l);\n\t\tL.Motion.Group.prototype.addLayer.call(this, l);\n\n\t\tif (!this._activeLayer && autostart && this._completed) {\n\t\t\tl.motionStart();\n\t\t}\n\t},\n\n\t/**\n\t\tStart first motion in current group;\n\t*/\n\tmotionStart: function() {\n\t\t// We will start animation only when its not running\n\t\tif (!this._activeLayer) {\n\t\t\tvar layer = this.getFirstLayer();\n\t\t\tif (layer) {\n\t\t\t\tlayer.motionStart();\n\t\t\t\tthis._started = true;\n\t\t\t\tthis._completed = false;\n\t\t\t\tthis.fire(L.Motion.Event.Started, {layer: this}, false);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n\t\tStops all motions in current group;\n\t*/\n\tmotionStop: function(softstop) {\n\t\tif (!softstop) {\n\t\t\tthis.invoke(\"motionStop\");\n\t\t}\n\t\tthis._activeLayer = null;\n\t\tthis._completed = true;\n\t\tthis.fire(L.Motion.Event.Ended, {layer: this}, false);\n\n\t\treturn this;\n\t},\n\n\t/**\n\t\tPause current motion in current group;\n\t*/\n\tmotionPause: function() {\n\t\tif (this._activeLayer) {\n\t\t\tthis._activeLayer.motionPause();\n\t\t\tthis.fire(L.Motion.Event.Paused, {layer: this}, false);\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n\t\tResume last motion in current group;\n\t*/\n\tmotionResume: function() {\n\t\tif (this._activeLayer) {\n\t\t\tthis._activeLayer.motionResume();\n\t\t\tthis.fire(L.Motion.Event.Resumed, {layer: this}, false);\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n\t\tReset all motions in current group;\n\t*/\n\tmotionToggle: function () {\n\t\tif (this._activeLayer) {\n\t\t\tthis.motionPause();\n\t\t} else {\n\t\t\tthis.motionResume();\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tgetFirstLayer: function() {\n\t\tvar allLayers = this.getLayers();\n\t\treturn allLayers.length ? allLayers[0] : null;\n\t},\n\n\t/**\n\t\tInitialise a layer so it's ready to be part of this motion sequence\n\t*/\n\t__prepareLayer: function (l) {\n\t\tif (l.setLatLngs) {\n\t\t\tl.setLatLngs([]);\n\t\t}\n\n\t\t// When a layer finishes have it remove itself and call motionStart() on the next layer\n\t\tl.off(L.Motion.Event.Ended, this.__clearActiveLayer__, this);\n\t\tl.on(L.Motion.Event.Ended, this.__clearActiveLayer__, this);\n\n\t\t// When a layer is started (by the last one ending) set it as the active layer\n\t\tl.off(L.Motion.Event.Started, this.__putActiveLayer__, this);\n\t\tl.on(L.Motion.Event.Started, this.__putActiveLayer__, this);\n\t},\n\n\t/**\n\t\tCalled by a layer (e.g. one of the sequence events) when it finishes. Is responsible for\n\t\tcleaning up after itself and starting the next layer.\n\t */\n\t__clearActiveLayer__: function (e) {\n\t\tthis._activeLayer = null;\n\t\tvar layers = this.getLayers();\n\t\tvar currentId = e.layer._leaflet_id;\n\t\tvar currentObject = layers.filter(function(f){ return f._leaflet_id == currentId })[0];\n\t\tvar nextIndex = layers.indexOf(currentObject) + 1;\n\t\tif (layers.length > nextIndex) {\n\t\t\tlayers[nextIndex].motionStart();\n\t\t} else {\n\t\t\t//this.fire(L.Motion.Event.Ended, {layer: this}, false);\n\t\t\tthis.motionStop(true);\n\t\t}\n\t},\n\n\t/**\n\t\tCalled by a layer when it's started, sets itself as the active layer on the sequence\n\t\tgroup and trigger any other events which need triggering.\n\t */\n\t__putActiveLayer__: function (e) {\n\t\tthis._activeLayer = e.layer;\n\t\tthis.fire(L.Motion.Event.Section, {layer: this._activeLayer}, false);\n\t}\n});\n\nL.motion.seq = function(motion, options){\n return new L.Motion.Seq(motion, options);\n};\n\n\n//# sourceURL=webpack://leaflet.motion/./src/layer/leaflet.motion.seq.js?"); /***/ }), @@ -143,10 +62,9 @@ eval("/**\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tA /*!**************************************!*\ !*** ./src/leaflet.motion.easing.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.Ease = {\n\tlinear: function( x ) {\n\t\treturn x;\n\t},\n\tswing: function( x ) {\n\t\treturn 0.5 - Math.cos( x * Math.PI ) / 2;\n\t},\n\teaseInQuad: function (x, t, b, c, d) {\n\t\treturn c*(t/=d)*t + b;\n\t},\n\teaseOutQuad: function (x, t, b, c, d) {\n\t\treturn -c *(t/=d)*(t-2) + b;\n\t},\n\teaseInOutQuad: function (x, t, b, c, d) {\n\t\tif ((t/=d/2) < 1) return c/2*t*t + b;\n\t\treturn -c/2 * ((--t)*(t-2) - 1) + b;\n\t},\n\teaseInCubic: function (x, t, b, c, d) {\n\t\treturn c*(t/=d)*t*t + b;\n\t},\n\teaseOutCubic: function (x, t, b, c, d) {\n\t\treturn c*((t=t/d-1)*t*t + 1) + b;\n\t},\n\teaseInOutCubic: function (x, t, b, c, d) {\n\t\tif ((t/=d/2) < 1) return c/2*t*t*t + b;\n\t\treturn c/2*((t-=2)*t*t + 2) + b;\n\t},\n\teaseInQuart: function (x, t, b, c, d) {\n\t\treturn c*(t/=d)*t*t*t + b;\n\t},\n\teaseOutQuart: function (x, t, b, c, d) {\n\t\treturn -c * ((t=t/d-1)*t*t*t - 1) + b;\n\t},\n\teaseInOutQuart: function (x, t, b, c, d) {\n\t\tif ((t/=d/2) < 1) return c/2*t*t*t*t + b;\n\t\treturn -c/2 * ((t-=2)*t*t*t - 2) + b;\n\t},\n\teaseInQuint: function (x, t, b, c, d) {\n\t\treturn c*(t/=d)*t*t*t*t + b;\n\t},\n\teaseOutQuint: function (x, t, b, c, d) {\n\t\treturn c*((t=t/d-1)*t*t*t*t + 1) + b;\n\t},\n\teaseInOutQuint: function (x, t, b, c, d) {\n\t\tif ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;\n\t\treturn c/2*((t-=2)*t*t*t*t + 2) + b;\n\t},\n\teaseInSine: function (x, t, b, c, d) {\n\t\treturn -c * Math.cos(t/d * (Math.PI/2)) + c + b;\n\t},\n\teaseOutSine: function (x, t, b, c, d) {\n\t\treturn c * Math.sin(t/d * (Math.PI/2)) + b;\n\t},\n\teaseInOutSine: function (x, t, b, c, d) {\n\t\treturn -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;\n\t},\n\teaseInExpo: function (x, t, b, c, d) {\n\t\treturn (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;\n\t},\n\teaseOutExpo: function (x, t, b, c, d) {\n\t\treturn (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;\n\t},\n\teaseInOutExpo: function (x, t, b, c, d) {\n\t\tif (t==0) return b;\n\t\tif (t==d) return b+c;\n\t\tif ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;\n\t\treturn c/2 * (-Math.pow(2, -10 * --t) + 2) + b;\n\t},\n\teaseInCirc: function (x, t, b, c, d) {\n\t\treturn -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;\n\t},\n\teaseOutCirc: function (x, t, b, c, d) {\n\t\treturn c * Math.sqrt(1 - (t=t/d-1)*t) + b;\n\t},\n\teaseInOutCirc: function (x, t, b, c, d) {\n\t\tif ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;\n\t\treturn c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;\n\t},\n\teaseInElastic: function (x, t, b, c, d) {\n\t\tvar s=1.70158;var p=0;var a=c;\n\t\tif (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;\n\t\tif (a < Math.abs(c)) { a=c; var s=p/4; }\n\t\telse var s = p/(2*Math.PI) * Math.asin (c/a);\n\t\treturn -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;\n\t},\n\teaseOutElastic: function (x, t, b, c, d) {\n\t\tvar s=1.70158;var p=0;var a=c;\n\t\tif (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;\n\t\tif (a < Math.abs(c)) { a=c; var s=p/4; }\n\t\telse var s = p/(2*Math.PI) * Math.asin (c/a);\n\t\treturn a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;\n\t},\n\teaseInOutElastic: function (x, t, b, c, d) {\n\t\tvar s=1.70158;var p=0;var a=c;\n\t\tif (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);\n\t\tif (a < Math.abs(c)) { a=c; var s=p/4; }\n\t\telse var s = p/(2*Math.PI) * Math.asin (c/a);\n\t\tif (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;\n\t\treturn a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;\n\t},\n\teaseInBack: function (x, t, b, c, d, s) {\n\t\tif (s == undefined) s = 1.70158;\n\t\treturn c*(t/=d)*t*((s+1)*t - s) + b;\n\t},\n\teaseOutBack: function (x, t, b, c, d, s) {\n\t\tif (s == undefined) s = 1.70158;\n\t\treturn c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;\n\t},\n\teaseInOutBack: function (x, t, b, c, d, s) {\n\t\tif (s == undefined) s = 1.70158;\n\t\tif ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;\n\t\treturn c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;\n\t},\n\teaseInBounce: function (x, t, b, c, d) {\n\t\treturn c - L.Motion.Ease.easeOutBounce (x, d-t, 0, c, d) + b;\n\t},\n\teaseOutBounce: function (x, t, b, c, d) {\n\t\tif ((t/=d) < (1/2.75)) {\n\t\t\treturn c*(7.5625*t*t) + b;\n\t\t} else if (t < (2/2.75)) {\n\t\t\treturn c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;\n\t\t} else if (t < (2.5/2.75)) {\n\t\t\treturn c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;\n\t\t} else {\n\t\t\treturn c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;\n\t\t}\n\t},\n\teaseInOutBounce: function (x, t, b, c, d) {\n\t\tif (t < d/2) return L.Motion.Ease.easeInBounce (x, t*2, 0, c, d) * .5 + b;\n\t\treturn L.Motion.Ease.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;\n\t}\n};\n\n\n//# sourceURL=webpack:///./src/leaflet.motion.easing.js?"); +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.Ease = {\n\tlinear: function( x ) {\n\t\treturn x;\n\t},\n\tswing: function( x ) {\n\t\treturn 0.5 - Math.cos( x * Math.PI ) / 2;\n\t},\n\teaseInQuad: function (x, t, b, c, d) {\n\t\treturn c*(t/=d)*t + b;\n\t},\n\teaseOutQuad: function (x, t, b, c, d) {\n\t\treturn -c *(t/=d)*(t-2) + b;\n\t},\n\teaseInOutQuad: function (x, t, b, c, d) {\n\t\tif ((t/=d/2) < 1) return c/2*t*t + b;\n\t\treturn -c/2 * ((--t)*(t-2) - 1) + b;\n\t},\n\teaseInCubic: function (x, t, b, c, d) {\n\t\treturn c*(t/=d)*t*t + b;\n\t},\n\teaseOutCubic: function (x, t, b, c, d) {\n\t\treturn c*((t=t/d-1)*t*t + 1) + b;\n\t},\n\teaseInOutCubic: function (x, t, b, c, d) {\n\t\tif ((t/=d/2) < 1) return c/2*t*t*t + b;\n\t\treturn c/2*((t-=2)*t*t + 2) + b;\n\t},\n\teaseInQuart: function (x, t, b, c, d) {\n\t\treturn c*(t/=d)*t*t*t + b;\n\t},\n\teaseOutQuart: function (x, t, b, c, d) {\n\t\treturn -c * ((t=t/d-1)*t*t*t - 1) + b;\n\t},\n\teaseInOutQuart: function (x, t, b, c, d) {\n\t\tif ((t/=d/2) < 1) return c/2*t*t*t*t + b;\n\t\treturn -c/2 * ((t-=2)*t*t*t - 2) + b;\n\t},\n\teaseInQuint: function (x, t, b, c, d) {\n\t\treturn c*(t/=d)*t*t*t*t + b;\n\t},\n\teaseOutQuint: function (x, t, b, c, d) {\n\t\treturn c*((t=t/d-1)*t*t*t*t + 1) + b;\n\t},\n\teaseInOutQuint: function (x, t, b, c, d) {\n\t\tif ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;\n\t\treturn c/2*((t-=2)*t*t*t*t + 2) + b;\n\t},\n\teaseInSine: function (x, t, b, c, d) {\n\t\treturn -c * Math.cos(t/d * (Math.PI/2)) + c + b;\n\t},\n\teaseOutSine: function (x, t, b, c, d) {\n\t\treturn c * Math.sin(t/d * (Math.PI/2)) + b;\n\t},\n\teaseInOutSine: function (x, t, b, c, d) {\n\t\treturn -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;\n\t},\n\teaseInExpo: function (x, t, b, c, d) {\n\t\treturn (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;\n\t},\n\teaseOutExpo: function (x, t, b, c, d) {\n\t\treturn (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;\n\t},\n\teaseInOutExpo: function (x, t, b, c, d) {\n\t\tif (t==0) return b;\n\t\tif (t==d) return b+c;\n\t\tif ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;\n\t\treturn c/2 * (-Math.pow(2, -10 * --t) + 2) + b;\n\t},\n\teaseInCirc: function (x, t, b, c, d) {\n\t\treturn -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;\n\t},\n\teaseOutCirc: function (x, t, b, c, d) {\n\t\treturn c * Math.sqrt(1 - (t=t/d-1)*t) + b;\n\t},\n\teaseInOutCirc: function (x, t, b, c, d) {\n\t\tif ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;\n\t\treturn c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;\n\t},\n\teaseInElastic: function (x, t, b, c, d) {\n\t\tvar s=1.70158;var p=0;var a=c;\n\t\tif (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;\n\t\tif (a < Math.abs(c)) { a=c; var s=p/4; }\n\t\telse var s = p/(2*Math.PI) * Math.asin (c/a);\n\t\treturn -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;\n\t},\n\teaseOutElastic: function (x, t, b, c, d) {\n\t\tvar s=1.70158;var p=0;var a=c;\n\t\tif (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;\n\t\tif (a < Math.abs(c)) { a=c; var s=p/4; }\n\t\telse var s = p/(2*Math.PI) * Math.asin (c/a);\n\t\treturn a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;\n\t},\n\teaseInOutElastic: function (x, t, b, c, d) {\n\t\tvar s=1.70158;var p=0;var a=c;\n\t\tif (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);\n\t\tif (a < Math.abs(c)) { a=c; var s=p/4; }\n\t\telse var s = p/(2*Math.PI) * Math.asin (c/a);\n\t\tif (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;\n\t\treturn a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;\n\t},\n\teaseInBack: function (x, t, b, c, d, s) {\n\t\tif (s == undefined) s = 1.70158;\n\t\treturn c*(t/=d)*t*((s+1)*t - s) + b;\n\t},\n\teaseOutBack: function (x, t, b, c, d, s) {\n\t\tif (s == undefined) s = 1.70158;\n\t\treturn c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;\n\t},\n\teaseInOutBack: function (x, t, b, c, d, s) {\n\t\tif (s == undefined) s = 1.70158;\n\t\tif ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;\n\t\treturn c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;\n\t},\n\teaseInBounce: function (x, t, b, c, d) {\n\t\treturn c - L.Motion.Ease.easeOutBounce (x, d-t, 0, c, d) + b;\n\t},\n\teaseOutBounce: function (x, t, b, c, d) {\n\t\tif ((t/=d) < (1/2.75)) {\n\t\t\treturn c*(7.5625*t*t) + b;\n\t\t} else if (t < (2/2.75)) {\n\t\t\treturn c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;\n\t\t} else if (t < (2.5/2.75)) {\n\t\t\treturn c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;\n\t\t} else {\n\t\t\treturn c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;\n\t\t}\n\t},\n\teaseInOutBounce: function (x, t, b, c, d) {\n\t\tif (t < d/2) return L.Motion.Ease.easeInBounce (x, t*2, 0, c, d) * .5 + b;\n\t\treturn L.Motion.Ease.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;\n\t}\n};\n\n\n//# sourceURL=webpack://leaflet.motion/./src/leaflet.motion.easing.js?"); /***/ }), @@ -154,10 +72,9 @@ eval("/**\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tA /*!*******************************!*\ !*** ./src/leaflet.motion.js ***! \*******************************/ -/*! no static exports found */ -/***/ (function(module, exports) { +/***/ (() => { -eval("/**\r\n\tMIT License http://www.opensource.org/licenses/mit-license.php\r\n\tAuthor Igor Vladyka (https://github.com/Igor-Vladyka/leaflet.motion)\r\n**/\r\n\r\nL.Motion = L.Motion || {\r\n\tEvent: {\r\n\t\t\tStarted:\"motion-started\",\r\n\t\t\tPaused: \"motion-paused\",\r\n\t\t\tResumed: \"motion-resumed\",\r\n\t\t\tSection: \"motion-section\",\r\n\t\t\tEnded: \"motion-ended\"\r\n\t\t}\r\n\t};\r\n\r\nL.motion = L.motion || {};\r\nL.Motion.Animate = {\r\n\toptions: {\r\n\t\tpane: \"polymotionPane\",\r\n\t\tattribution: \"Leaflet.Motion © \" + (new Date()).getFullYear() + \" Igor Vladyka\"\r\n\t},\r\n\r\n\tmotionOptions: {\r\n\t\tauto: false,\r\n\t\teasing: function(x){ return x; }, // linear\r\n\t\tspeed: 0, // KM/H\r\n\t\tduration: 0 // ms\r\n\t},\r\n\r\n\tmarkerOptions: undefined,\r\n\r\n\tinitialize: function (latlngs, options, motionOptions, markerOptions) {\r\n\t\tL.Util.setOptions(this, options);\r\n\t\tif (motionOptions) {\r\n\t\t\tthis.motionOptions = L.Util.extend({}, this.motionOptions, motionOptions);\r\n\t\t}\r\n\r\n\t\tif (markerOptions) {\r\n\t\t\tthis.markerOptions = L.Util.extend({}, markerOptions);\r\n\t\t}\r\n\r\n\t\tthis._bounds = L.latLngBounds();\r\n\t\tthis._linePoints = this._convertLatLngs(latlngs);\r\n\t\tif (!L.Motion.Utils.isFlat(this._linePoints)) {\r\n\t\t\tthis._linePoints = this._linePoints[0];\r\n\t\t}\r\n\r\n\t\tthis._initializeMarker();\r\n\t\tthis._latlngs = [];\r\n\t\tL.Util.stamp(this); // Enforce proper animation order;\r\n\t},\r\n\r\n\taddLatLng: function(latLng, ring) {\r\n\t\tlatLng = L.Motion.Utils.toLatLng(latLng);\r\n\t\tthis._linePoints.push(latLng);\r\n\t\tif (this._latlngs.length) {\r\n\t\t\tthis._latlngs.push(latLng);\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t/**\r\n @param {Map} map the Leaflet Map\r\n */\r\n\tbeforeAdd: function (map) {\r\n\t\tif (!map.getPane(this.options.pane)) {\r\n\t\t\tmap.createPane(this.options.pane).style.zIndex = 599;\r\n\t\t}\r\n\r\n\t\tthis._renderer = map.getRenderer(this);\r\n\t},\r\n\r\n\t/**\r\n @param {Map} map the Leaflet Map\r\n\t\t@return {MotionObject} this\r\n */\r\n onAdd: function (map) {\r\n\t\tthis._renderer._initPath(this);\r\n\t\tthis._reset();\r\n\t\tthis._renderer._addPath(this);\r\n\t\tif (this.__marker && this.markerOptions.showMarker) {\r\n\t\t\tthis.__marker.addTo(map);\r\n\r\n\t\t\tif(this.__marker._icon && this.__marker._icon.children.length){\r\n\t\t\t\tArray.from(this.__marker._icon.children).forEach(function(icon) {\r\n\t\t\t\t\tvar baseRotationAngle = icon.getAttribute(\"motion-base\");\r\n\t\t\t\t\tif (baseRotationAngle) {\r\n\t\t\t\t\t\ticon.style.transform = \"rotate(\" + baseRotationAngle + \"deg)\";\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (this.motionOptions.auto) {\r\n\t\t\tthis.motionStart();\r\n\t\t}\r\n\r\n return this;\r\n },\r\n\r\n\t/**\r\n @param {Map} map the Leaflet Map\r\n */\r\n\tonRemove: function (map) {\r\n\t\tthis.motionStop();\r\n\t\tif (this.__marker) {\r\n\t\t\tmap.removeLayer(this.__marker);\r\n\t\t}\r\n\r\n\t\tthis._renderer._removePath(this);\r\n\t},\r\n\r\n\t/**\r\n @param {DateTime} startTime time from start animation\r\n */\r\n _motion: function (startTime) {\r\n\t\tvar ellapsedTime = (new Date()).getTime() - startTime;\r\n var durationRatio = 1; // 0 - 1\r\n\t\tif (this.motionOptions.duration) {\r\n\t\t\tdurationRatio = ellapsedTime / this.motionOptions.duration;\r\n\t\t}\r\n\r\n\t\tif (durationRatio < 1) {\r\n\t\t\tdurationRatio = this.motionOptions.easing(durationRatio, ellapsedTime, 0, 1, this.motionOptions.duration);\r\n\t\t\tvar interpolatedLine = L.Motion.Utils.interpolateOnLine(this._map, this._linePoints, durationRatio);\r\n\r\n\t\t\tthis.setLatLngs(interpolatedLine.traveledPath);\r\n\t\t\tthis._drawMarker(interpolatedLine.latLng);\r\n\r\n\t\t\tthis.__ellapsedTime = ellapsedTime;\r\n\t\t\tthis.animation = L.Util.requestAnimFrame(function(){\r\n\t\t\t\tthis._motion(startTime);\r\n\t\t\t}, this);\r\n\t\t} else {\r\n\t\t\tthis.motionStop(true);\r\n\t\t}\r\n },\r\n\r\n\t/**\r\n\t\tDraws marker according to line position\r\n @param {LatLng} nextPoint next animation point\r\n */\r\n\t_drawMarker: function (nextPoint) {\r\n\t\tvar marker = this.getMarker();\r\n\t\tif (marker) {\r\n\t\t\tvar prevPoint = marker.getLatLng();\r\n\r\n\t\t\t// [0, 0] Means that marker is not added yet to the map\r\n\t\t\tvar initialPoints = this._linePoints[0];\r\n\t\t\tif (prevPoint.lat === initialPoints.lat && prevPoint.lng === initialPoints.lng) {\r\n\t\t\t\tmarker.addTo(this._map);\r\n\t\t\t\tmarker.addEventParent(this);\r\n\t\t\t} else {\r\n\t\t\t\tif (marker._icon && marker._icon.children.length) {\r\n\t\t\t\t\tArray.from(marker._icon.children).forEach(function(icon) {\r\n\t\t\t\t\t\tvar needToRotateMarker = icon.getAttribute(\"motion-base\");\r\n\r\n\t\t\t\t\t\tif (needToRotateMarker) {\r\n\t\t\t\t\t\t\tvar motionMarkerOnLine = 0;\r\n\t\t\t\t\t\t\tif (needToRotateMarker && !isNaN(+needToRotateMarker)) {\r\n\t\t\t\t\t\t\t\tmotionMarkerOnLine = +needToRotateMarker;\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\ticon.style.transform = \"rotate(-\" + Math.round(L.Motion.Utils.getAngle(prevPoint, nextPoint) + motionMarkerOnLine) +\"deg)\";\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tmarker.setLatLng(nextPoint);\r\n\t\t}\r\n\t},\r\n\r\n\t/**\r\n Removes marker from the map\r\n */\r\n\t_removeMarker: function (animEnded) {\r\n\t\tif (this.markerOptions && this.__marker) {\r\n\t\t\tif (!animEnded || this.markerOptions.removeOnEnd) {\r\n\t\t\t\tthis._map.removeLayer(this.__marker);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t/**\r\n Initialize marker from marker options and add it to the map if needed\r\n */\r\n\t_initializeMarker: function () {\r\n\t\tif (this.markerOptions) {\r\n\t\t\tthis.__marker = L.marker(this._linePoints[0], this.markerOptions);\r\n\t\t}\r\n\t},\r\n\r\n\t/**\r\n Starts animation of current object\r\n */\r\n\tmotionStart: function () {\r\n\t\tif (this._map && !this.animation) {\r\n\t\t\tif (!this.motionOptions.duration) {\r\n\t\t\t\tif (this.motionOptions.speed) {\r\n\t\t\t\t\tthis.motionOptions.duration = L.Motion.Utils.getDuration(this._map, this._linePoints, this.motionOptions.speed);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.motionOptions.duration = 0;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis.setLatLngs([]);\r\n\t this._motion((new Date).getTime());\r\n\t\t\tthis.fire(L.Motion.Event.Started, {layer: this}, false);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n },\r\n\r\n\t/**\r\n Stops animation of current object\r\n @param {LatLng[]} points full object points collection or empty collection for cleanup\r\n */\r\n motionStop: function (animEnded) {\r\n\t\tthis.motionPause();\r\n\t\tthis.setLatLngs(this._linePoints);\r\n\t\tthis.__ellapsedTime = null;\r\n\t\tthis._removeMarker(animEnded);\r\n\t\tthis.fire(L.Motion.Event.Ended, {layer: this}, false);\r\n\r\n\t\treturn this;\r\n },\r\n\r\n\t/**\r\n Pauses animation of current object\r\n */\r\n\tmotionPause: function () {\r\n\t\tif (this.animation) {\r\n\t\t\tL.Util.cancelAnimFrame(this.animation);\r\n\t\t\tthis.animation = null;\r\n\t\t\tthis.fire(L.Motion.Event.Paused, {layer: this}, false);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t/**\r\n Resume animation of current object\r\n */\r\n\tmotionResume: function () {\r\n\t\tif (!this.animation && this.__ellapsedTime) {\r\n\t\t\tif (!this.motionOptions.duration) {\r\n\t\t\t\tif (this.motionOptions.speed) {\r\n\t\t\t\t\tthis.motionOptions.duration = L.Motion.Utils.getDuration(this._map, this._linePoints, this.motionOptions.speed);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.motionOptions.duration = 0;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis._motion((new Date).getTime() - (this.__ellapsedTime));\r\n\t\t\tthis.fire(L.Motion.Event.Resumed, {layer: this}, false);\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t/**\r\n Toggles animation of current object; Start/Pause/Resume;\r\n */\r\n\tmotionToggle: function () {\r\n\t\tif (this.animation) {\r\n\t\t\tif (this.__ellapsedTime) {\r\n\t\t\t\tthis.motionPause();\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tif (this.__ellapsedTime) {\r\n\t\t\t\tthis.motionResume();\r\n\t\t\t} else {\r\n\t\t\t\tthis.motionStart();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t/**\r\n\t\tSetup motion duration at any time\r\n\t*/\r\n\tmotionDuration: function (duration) {\r\n\t\tvar prevDuration = this.motionSpeed.duration;\r\n\t\tthis.motionOptions.duration = duration || 0;\r\n\r\n\t\tif (this.animation && prevDuration) {\r\n\t\t\tthis.motionPause();\r\n\t\t this.__ellapsedTime = this.__ellapsedTime * (prevDuration / duration);\r\n\t\t this.motionOptions.duration = duration;\r\n\t\t\tthis.motionResume();\r\n\t\t}\r\n\t\treturn this;\r\n\t},\r\n\r\n\t/**\r\n\t\tSetup motion speed at any time\r\n\t*/\r\n\tmotionSpeed: function (speed) {\r\n\t\tvar prevSpeed = this.motionOptions.speed;\r\n\t\tthis.motionOptions.speed = speed || 0;\r\n\r\n\t\tif (this.animation && prevSpeed) {\r\n\t\t\tthis.motionPause();\r\n\t\t this.__ellapsedTime = this.__ellapsedTime * (prevSpeed / speed);\r\n\t\t this.motionOptions.duration = L.Motion.Utils.getDuration(this._map, this._linePoints, this.motionOptions.speed);\r\n\t\t\tthis.motionResume();\r\n\t\t}\r\n\r\n\t\treturn this;\r\n\t},\r\n\r\n\t/**\r\n\t\tReturns current constructed marker\r\n\t*/\r\n\tgetMarker: function () {\r\n\t\treturn this.__marker;\r\n\t},\r\n\r\n\t/**\r\n\t\tReturns markers array from all inner layers without flattering.\r\n\t*/\r\n\tgetMarkers: function () {\r\n\t\treturn [this.getMarker()];\r\n\t}\r\n}\r\n\n\n//# sourceURL=webpack:///./src/leaflet.motion.js?"); +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 = L.Motion || {\n\tEvent: {\n\t\t\tStarted:\"motion-started\",\n\t\t\tPaused: \"motion-paused\",\n\t\t\tResumed: \"motion-resumed\",\n\t\t\tSection: \"motion-section\",\n\t\t\tEnded: \"motion-ended\"\n\t\t}\n\t};\n\nL.motion = L.motion || {};\nL.Motion.Animate = {\n\toptions: {\n\t\tpane: \"polymotionPane\",\n\t\tattribution: \"Leaflet.Motion © \" + (new Date()).getFullYear() + \" Igor Vladyka\"\n\t},\n\n\tmotionOptions: {\n\t\tauto: false,\n\t\teasing: function(x){ return x; }, // linear\n\t\tspeed: 0, // KM/H\n\t\tduration: 0 // ms\n\t},\n\n\tmarkerOptions: undefined,\n\n\tinitialize: function (latlngs, options, motionOptions, markerOptions) {\n\t\tL.Util.setOptions(this, options);\n\t\tif (motionOptions) {\n\t\t\tthis.motionOptions = L.Util.extend({}, this.motionOptions, motionOptions);\n\t\t}\n\n\t\tif (markerOptions) {\n\t\t\tthis.markerOptions = L.Util.extend({}, markerOptions);\n\t\t}\n\n\t\tthis._bounds = L.latLngBounds();\n\t\tthis._linePoints = this._convertLatLngs(latlngs);\n\t\tif (!L.Motion.Utils.isFlat(this._linePoints)) {\n\t\t\tthis._linePoints = this._linePoints[0];\n\t\t}\n\n\t\tthis._initializeMarker();\n\t\tthis._latlngs = [];\n\t\tL.Util.stamp(this); // Enforce proper animation order;\n\t},\n\n\taddLatLng: function(latLng, ring) {\n\t\tlatLng = L.Motion.Utils.toLatLng(latLng);\n\t\tthis._linePoints.push(latLng);\n\t\tif (this._latlngs.length) {\n\t\t\tthis._latlngs.push(latLng);\n\t\t}\n\t\treturn this;\n\t},\n\n\t/**\n @param {Map} map the Leaflet Map\n */\n\tbeforeAdd: function (map) {\n\t\tif (!map.getPane(this.options.pane)) {\n\t\t\tmap.createPane(this.options.pane).style.zIndex = 599;\n\t\t}\n\n\t\tthis._renderer = map.getRenderer(this);\n\t},\n\n\t/**\n @param {Map} map the Leaflet Map\n\t\t@return {MotionObject} this\n */\n onAdd: function (map) {\n\t\tthis._renderer._initPath(this);\n\t\tthis._reset();\n\t\tthis._renderer._addPath(this);\n\t\tif (this.__marker && this.markerOptions.showMarker) {\n\t\t\tthis.__marker.addTo(map);\n\n\t\t\tif(this.__marker._icon && this.__marker._icon.children.length){\n\t\t\t\tArray.from(this.__marker._icon.children).forEach(function(icon) {\n\t\t\t\t\tvar baseRotationAngle = icon.getAttribute(\"motion-base\");\n\t\t\t\t\tif (baseRotationAngle) {\n\t\t\t\t\t\ticon.style.transform = \"rotate(\" + baseRotationAngle + \"deg)\";\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (this.motionOptions.auto) {\n\t\t\tthis.motionStart();\n\t\t}\n\n return this;\n },\n\n\t/**\n @param {Map} map the Leaflet Map\n */\n\tonRemove: function (map) {\n\t\tthis.motionStop();\n\t\tif (this.__marker) {\n\t\t\tmap.removeLayer(this.__marker);\n\t\t}\n\n\t\tthis._renderer._removePath(this);\n\t},\n\n\t/**\n @param {DateTime} startTime time from start animation\n */\n _motion: function (startTime) {\n\t\tvar ellapsedTime = (new Date()).getTime() - startTime;\n var durationRatio = 1; // 0 - 1\n\t\tif (this.motionOptions.duration) {\n\t\t\tdurationRatio = ellapsedTime / this.motionOptions.duration;\n\t\t}\n\n\t\tif (durationRatio < 1) {\n\t\t\tdurationRatio = this.motionOptions.easing(durationRatio, ellapsedTime, 0, 1, this.motionOptions.duration);\n\t\t\tvar interpolatedLine = L.Motion.Utils.interpolateOnLine(this._map, this._linePoints, durationRatio);\n\n\t\t\tthis.setLatLngs(interpolatedLine.traveledPath);\n\t\t\tthis._drawMarker(interpolatedLine.latLng);\n\n\t\t\tif(this.options.onTick) { this.options.onTick.bind(this)(nextPoint); }\n\n\t\t\tthis.__ellapsedTime = ellapsedTime;\n\t\t\tthis.animation = L.Util.requestAnimFrame(function(){\n\t\t\t\tthis._motion(startTime);\n\t\t\t}, this);\n\t\t} else {\n\t\t\tthis.motionStop(true);\n\t\t}\n },\n\n\t/**\n\t\tDraws marker according to line position\n @param {LatLng} nextPoint next animation point\n */\n\t_drawMarker: function (nextPoint) {\n\t\tvar marker = this.getMarker();\n\t\tif (marker) {\n\t\t\tvar prevPoint = marker.getLatLng();\n\n\t\t\t// [0, 0] Means that marker is not added yet to the map\n\t\t\tvar initialPoints = this._linePoints[0];\n\t\t\tif (prevPoint.lat === initialPoints.lat && prevPoint.lng === initialPoints.lng) {\n\t\t\t\tmarker.addTo(this._map);\n\t\t\t\tmarker.addEventParent(this);\n\t\t\t} else {\n\t\t\t\tif (marker._icon && marker._icon.children.length) {\n\t\t\t\t\tArray.from(marker._icon.children).forEach(function(icon) {\n\t\t\t\t\t\tvar needToRotateMarker = icon.getAttribute(\"motion-base\");\n\n\t\t\t\t\t\tif (needToRotateMarker) {\n\t\t\t\t\t\t\tvar motionMarkerOnLine = 0;\n\t\t\t\t\t\t\tif (needToRotateMarker && !isNaN(+needToRotateMarker)) {\n\t\t\t\t\t\t\t\tmotionMarkerOnLine = +needToRotateMarker;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst markerAngle = -1 * Math.round(L.Motion.Utils.getAngle(prevPoint, nextPoint) + motionMarkerOnLine);\n\t\t\t\t\t\t\ticon.style.transform = `rotate(${markerAngle}deg)`;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmarker.setLatLng(nextPoint);\n\t\t}\n\t},\n\n\t/**\n Removes marker from the map\n */\n\t_removeMarker: function (animEnded) {\n\t\tif (this.markerOptions && this.__marker) {\n\t\t\tif (!animEnded || this.markerOptions.removeOnEnd) {\n\t\t\t\tthis._map.removeLayer(this.__marker);\n\t\t\t}\n\t\t}\n\t},\n\n\t/**\n Initialize marker from marker options and add it to the map if needed\n */\n\t_initializeMarker: function () {\n\t\tif (this.markerOptions) {\n\t\t\tthis.__marker = L.marker(this._linePoints[0], this.markerOptions);\n\t\t}\n\t},\n\n\t/**\n Starts animation of current object\n */\n\tmotionStart: function () {\n\t\tif (this._map && !this.animation) {\n\t\t\tif (!this.motionOptions.duration) {\n\t\t\t\tif (this.motionOptions.speed) {\n\t\t\t\t\tthis.motionOptions.duration = L.Motion.Utils.getDuration(this._map, this._linePoints, this.motionOptions.speed);\n\t\t\t\t} else {\n\t\t\t\t\tthis.motionOptions.duration = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setLatLngs([]);\n\t this._motion((new Date).getTime());\n\t\t\tthis.fire(L.Motion.Event.Started, {layer: this}, false);\n\t\t}\n\n\t\treturn this;\n },\n\n\t/**\n Stops animation of current object\n @param {LatLng[]} points full object points collection or empty collection for cleanup\n */\n motionStop: function (animEnded) {\n\t\tthis.motionPause();\n\t\tthis.setLatLngs(this._linePoints);\n\t\tthis._drawMarker(this._linePoints[this._linePoints.length - 1]);\n\t\tthis.__ellapsedTime = null;\n\t\tthis._removeMarker(animEnded);\n\t\tthis.fire(L.Motion.Event.Ended, {layer: this}, false);\n\n\t\treturn this;\n },\n\n\t/**\n Pauses animation of current object\n */\n\tmotionPause: function () {\n\t\tif (this.animation) {\n\t\t\tL.Util.cancelAnimFrame(this.animation);\n\t\t\tthis.animation = null;\n\t\t\tthis.fire(L.Motion.Event.Paused, {layer: this}, false);\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n Resume animation of current object\n */\n\tmotionResume: function () {\n\t\tif (!this.animation && this.__ellapsedTime) {\n\t\t\tif (!this.motionOptions.duration) {\n\t\t\t\tif (this.motionOptions.speed) {\n\t\t\t\t\tthis.motionOptions.duration = L.Motion.Utils.getDuration(this._map, this._linePoints, this.motionOptions.speed);\n\t\t\t\t} else {\n\t\t\t\t\tthis.motionOptions.duration = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._motion((new Date).getTime() - (this.__ellapsedTime));\n\t\t\tthis.fire(L.Motion.Event.Resumed, {layer: this}, false);\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n Toggles animation of current object; Start/Pause/Resume;\n */\n\tmotionToggle: function () {\n\t\tif (this.animation) {\n\t\t\tif (this.__ellapsedTime) {\n\t\t\t\tthis.motionPause();\n\t\t\t}\n\t\t} else {\n\t\t\tif (this.__ellapsedTime) {\n\t\t\t\tthis.motionResume();\n\t\t\t} else {\n\t\t\t\tthis.motionStart();\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n\t\tSetup motion duration at any time\n\t*/\n\tmotionDuration: function (duration) {\n\t\tvar prevDuration = this.motionSpeed.duration;\n\t\tthis.motionOptions.duration = duration || 0;\n\n\t\tif (this.animation && prevDuration) {\n\t\t\tthis.motionPause();\n\t\t this.__ellapsedTime = this.__ellapsedTime * (prevDuration / duration);\n\t\t this.motionOptions.duration = duration;\n\t\t\tthis.motionResume();\n\t\t}\n\t\treturn this;\n\t},\n\n\t/**\n\t\tSetup motion speed at any time\n\t*/\n\tmotionSpeed: function (speed) {\n\t\tvar prevSpeed = this.motionOptions.speed;\n\t\tthis.motionOptions.speed = speed || 0;\n\n\t\tif (this.animation && prevSpeed) {\n\t\t\tthis.motionPause();\n\t\t this.__ellapsedTime = this.__ellapsedTime * (prevSpeed / speed);\n\t\t this.motionOptions.duration = L.Motion.Utils.getDuration(this._map, this._linePoints, this.motionOptions.speed);\n\t\t\tthis.motionResume();\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n\t\tReturns current constructed marker\n\t*/\n\tgetMarker: function () {\n\t\treturn this.__marker;\n\t},\n\n\t/**\n\t\tReturns markers array from all inner layers without flattering.\n\t*/\n\tgetMarkers: function () {\n\t\treturn [this.getMarker()];\n\t}\n}\n\n\n//# sourceURL=webpack://leaflet.motion/./src/leaflet.motion.js?"); /***/ }), @@ -165,22 +82,26 @@ eval("/**\r\n\tMIT License http://www.opensource.org/licenses/mit-license.php\r\ /*!*************************************!*\ !*** ./src/leaflet.motion.utils.js ***! \*************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("/**\r\n\tMIT License http://www.opensource.org/licenses/mit-license.php\r\n\tAuthor Igor Vladyka (https://github.com/Igor-Vladyka/leaflet.motion)\r\n**/\r\n\r\nL.Motion.Utils = {\r\n\t/**\r\n\t\tAttaches distances precalculated to current set of LatLng\r\n\t\t@param {L.Map} map Leaflet map to be calculate distances\r\n\t\t@param {Array|L.PolyLine} latlngs Set of geographical points\r\n\t\t@returns {Array|L.PolyLine} latlngs Set of geographical points with attached distances\r\n\t*/\r\n\tattachDistances: function(map, latLngs) {\r\n\t\tif (latLngs.length > 1) {\r\n\t\t\tfor (var i = 1; i < latLngs.length; i++) {\r\n\t\t\t\tlatLngs[i - 1].distanceToNextPoint = map.distance(latLngs[i - 1], latLngs[i]);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn latLngs;\r\n\t},\r\n\r\n\t/**\r\n\t\tReturns the coordinate of the point located on a line at the specified ratio of the line length.\r\n\t\t@param {L.Map} map Leaflet map to be used for this method\r\n\t\t@param {Array|L.PolyLine} latlngs Set of geographical points\r\n\t\t@param {Number} ratio the length ratio, expressed as a decimal between 0 and 1, inclusive\r\n\t\t@returns {Object} an object with latLng ({LatLng}) and predecessor ({Number}), the index of the preceding vertex in the Polyline\r\n\t\t(-1 if the interpolated point is the first vertex)\r\n\t*/\r\n\tinterpolateOnLine: function (map, latLngs, ratio) {\r\n\t\tlatLngs = (latLngs instanceof L.Polyline) ? latLngs.getLatLngs() : latLngs;\r\n\t\tif (latLngs.length < 2) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tvar allDistancesCalculated = true;\r\n\t\tfor (var d = 0; d < latLngs.length - 1; d++) {\r\n\t\t\tif (!latLngs[d].distanceToNextPoint) {\r\n\t\t\t\tallDistancesCalculated = false;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!allDistancesCalculated) {\r\n\t\t\tthis.attachDistances(map, latLngs);\r\n\t\t}\r\n\r\n\t\t// ensure the ratio is between 0 and 1;\r\n\t\tratio = Math.max(Math.min(ratio, 1), 0);\r\n\r\n\t\tif (ratio === 0) {\r\n\t\t\tvar singlePoint = latLngs[0] instanceof L.LatLng ? latLngs[0] : L.latLng(latLngs[0]);\r\n\t\t\treturn {\r\n\t\t\t\ttraveledPath: [singlePoint],\r\n\t\t\t\tlatLng: singlePoint\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\tif (ratio == 1) {\r\n\t\t\treturn {\r\n\t\t\t\ttraveledPath: latLngs,\r\n\t\t\t\tlatLng: latLngs[latLngs.length -1] instanceof L.LatLng ? latLngs[latLngs.length -1] : L.latLng(latLngs[latLngs.length -1])\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\t// get full line length between points\r\n\t\tvar fullLength = 0;\r\n\t\tfor (var dIndex = 0; dIndex < latLngs.length - 1; dIndex++) {\r\n\t\t\tfullLength += latLngs[dIndex].distanceToNextPoint;\r\n\t\t}\r\n\r\n\t\t// Calculate expected ratio\r\n\t\tvar ratioDist = fullLength * ratio;\r\n\r\n\t\t// follow the line segments [ab], adding lengths,\r\n\t\t// until we find the segment where the points should lie on\r\n\t\tvar cumulativeDistanceToA = 0, cumulativeDistanceToB = 0;\r\n\t\tfor (var i = 0; cumulativeDistanceToB < ratioDist; i++) {\r\n\t\t\tvar pointA = latLngs[i], pointB = latLngs[i+1];\r\n\r\n\t\t\tcumulativeDistanceToA = cumulativeDistanceToB;\r\n\t\t\tcumulativeDistanceToB += pointA.distanceToNextPoint;\r\n\t\t}\r\n\r\n\t\tif (pointA == undefined && pointB == undefined) { // Happens when line has no length\r\n\t\t\tvar pointA = latLngs[0], pointB = latLngs[1], i = 1;\r\n\t\t}\r\n\r\n\t\t// compute the ratio relative to the segment [ab]\r\n\t\tvar segmentRatio = ((cumulativeDistanceToB - cumulativeDistanceToA) !== 0) ? ((ratioDist - cumulativeDistanceToA) / (cumulativeDistanceToB - cumulativeDistanceToA)) : 0;\r\n\t\tvar interpolatedPoint = this.interpolateOnLatLngSegment(pointA, pointB, segmentRatio);\r\n\t\tvar traveledPath = latLngs.slice(0, i);\r\n\t\ttraveledPath.push(interpolatedPoint);\r\n\t\treturn {\r\n\t\t\ttraveledPath: traveledPath,\r\n\t\t\tlatLng: interpolatedPoint\r\n\t\t};\r\n\t},\r\n\r\n /**\r\n Returns the Point located on a segment at the specified ratio of the segment length.\r\n @param {L.Point} pA coordinates of point A\r\n @param {L.Point} pB coordinates of point B\r\n @param {Number} the length ratio, expressed as a decimal between 0 and 1, inclusive.\r\n @returns {L.Point} the interpolated point.\r\n */\r\n interpolateOnPointSegment: function (pA, pB, ratio) {\r\n return L.point(\r\n (pA.x * (1 - ratio)) + (ratio * pB.x),\r\n (pA.y * (1 - ratio)) + (ratio * pB.y)\r\n );\r\n },\r\n\r\n /**\r\n Returns the LatLng located on a segment at the specified ratio of the segment length.\r\n @param {L.LatLng} pA coordinates of LatLng A\r\n @param {L.LatLng} pB coordinates of LatLng B\r\n @param {Number} the length ratio, expressed as a decimal between 0 and 1, inclusive.\r\n @returns {L.LatLng} the interpolated LatLng.\r\n */\r\n interpolateOnLatLngSegment: function (pA, pB, ratio) {\r\n return L.latLng(\r\n (pA.lat * (1 - ratio)) + (ratio * pB.lat),\r\n (pA.lng * (1 - ratio)) + (ratio * pB.lng)\r\n );\r\n },\r\n\r\n\t/**\r\n\t\t@param {L.Map} map Leaflet map to be calculate distances\r\n @param {LatLng[]} linePoints of coordinates\r\n @return {Number} distance in meter\r\n */\r\n\tdistance: function(map, linePoints){\r\n\t\tvar distanceInMeter = 0;\r\n for (var i = 1; i < linePoints.length; i++) {\r\n distanceInMeter += map.distance(linePoints[i], linePoints[i - 1]);\r\n }\r\n\r\n return distanceInMeter;\r\n\t},\r\n\r\n\t/**\r\n\t\t@param {L.Map} map Leaflet map to be calculate distances\r\n @param {LatLng[]} collection of coordinates\r\n @param {Number} speed in KM/H\r\n @return {Number} duration in ms\r\n */\r\n\tgetDuration: function (map, collection, speed) {\r\n\t\tvar distance = L.Motion.Utils.distance(map, collection.map(function(m){ return L.Motion.Utils.toLatLng(m); })); // in meters;\r\n\t\treturn distance/(speed/3600); // m / (km/h * 1000 => m/h / (60 * 60)) => m / k/s (m/s * 1000) => 1000 * m / m/s => ms;\r\n\t},\r\n\r\n\ttoLatLng: function(a, b, c) {\r\n\t\tif (a instanceof L.LatLng) {\r\n\t\t\treturn a;\r\n\t\t}\r\n\t\tif (L.Util.isArray(a) && typeof a[0] !== 'object') {\r\n\t\t\tif (a.length === 3) {\r\n\t\t\t\treturn L.latLng(a[0], a[1], a[2]);\r\n\t\t\t}\r\n\t\t\tif (a.length === 2) {\r\n\t\t\t\treturn L.latLng(a[0], a[1]);\r\n\t\t\t}\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\tif (a === undefined || a === null) {\r\n\t\t\treturn a;\r\n\t\t}\r\n\t\tif (typeof a === 'object' && 'lat' in a) {\r\n\t\t\treturn L.latLng(a.lat, 'lng' in a ? a.lng : a.lon, a.alt);\r\n\t\t}\r\n\t\tif (b === undefined) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\treturn L.latLng(a, b, c);\r\n\t},\r\n\r\n\tgetAngle: function(prevPoint, nextPoint) {\r\n\t\tvar angle = Math.atan2(nextPoint.lat - prevPoint.lat, nextPoint.lng - prevPoint.lng) * 180 / Math.PI;\r\n\t\tif (angle < 0) {\r\n\t\t\tangle += 360;\r\n\t\t}\r\n\r\n\t\treturn angle;\r\n\t},\r\n\r\n\t// Leaflet -> geometries -> LineUtil\r\n\tisFlat: function (latlngs) {\r\n\t\treturn !L.Util.isArray(latlngs[0]) || (typeof latlngs[0][0] !== 'object' && typeof latlngs[0][0] !== 'undefined');\r\n\t}\r\n};\r\n\n\n//# sourceURL=webpack:///./src/leaflet.motion.utils.js?"); +/***/ (() => { -/***/ }), - -/***/ 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.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.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?"); +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.Utils = {\n\t/**\n\t\tAttaches distances precalculated to current set of LatLng\n\t\t@param {L.Map} map Leaflet map to be calculate distances\n\t\t@param {Array|L.PolyLine} latlngs Set of geographical points\n\t\t@returns {Array|L.PolyLine} latlngs Set of geographical points with attached distances\n\t*/\n\tattachDistances: function(map, latLngs) {\n\t\tif (latLngs.length > 1) {\n\t\t\tfor (var i = 1; i < latLngs.length; i++) {\n\t\t\t\tlatLngs[i - 1].distanceToNextPoint = map.distance(latLngs[i - 1], latLngs[i]);\n\t\t\t}\n\t\t}\n\n\t\treturn latLngs;\n\t},\n\n\t/**\n\t\tReturns the coordinate of the point located on a line at the specified ratio of the line length.\n\t\t@param {L.Map} map Leaflet map to be used for this method\n\t\t@param {Array|L.PolyLine} latlngs Set of geographical points\n\t\t@param {Number} ratio the length ratio, expressed as a decimal between 0 and 1, inclusive\n\t\t@returns {Object} an object with latLng ({LatLng}) and predecessor ({Number}), the index of the preceding vertex in the Polyline\n\t\t(-1 if the interpolated point is the first vertex)\n\t*/\n\tinterpolateOnLine: function (map, latLngs, ratio) {\n\t\tlatLngs = (latLngs instanceof L.Polyline) ? latLngs.getLatLngs() : latLngs;\n\t\tif (latLngs.length < 2) {\n\t\t\treturn null;\n\t\t}\n\n\t\tvar allDistancesCalculated = true;\n\t\tfor (var d = 0; d < latLngs.length - 1; d++) {\n\t\t\tif (!latLngs[d].distanceToNextPoint) {\n\t\t\t\tallDistancesCalculated = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (!allDistancesCalculated) {\n\t\t\tthis.attachDistances(map, latLngs);\n\t\t}\n\n\t\t// ensure the ratio is between 0 and 1;\n\t\tratio = Math.max(Math.min(ratio, 1), 0);\n\n\t\tif (ratio === 0) {\n\t\t\tvar singlePoint = latLngs[0] instanceof L.LatLng ? latLngs[0] : L.latLng(latLngs[0]);\n\t\t\treturn {\n\t\t\t\ttraveledPath: [singlePoint],\n\t\t\t\tlatLng: singlePoint\n\t\t\t};\n\t\t}\n\n\t\tif (ratio == 1) {\n\t\t\treturn {\n\t\t\t\ttraveledPath: latLngs,\n\t\t\t\tlatLng: latLngs[latLngs.length -1] instanceof L.LatLng ? latLngs[latLngs.length -1] : L.latLng(latLngs[latLngs.length -1])\n\t\t\t};\n\t\t}\n\n\t\t// get full line length between points\n\t\tvar fullLength = 0;\n\t\tfor (var dIndex = 0; dIndex < latLngs.length - 1; dIndex++) {\n\t\t\tfullLength += latLngs[dIndex].distanceToNextPoint;\n\t\t}\n\n\t\t// Calculate expected ratio\n\t\tvar ratioDist = fullLength * ratio;\n\n\t\t// follow the line segments [ab], adding lengths,\n\t\t// until we find the segment where the points should lie on\n\t\tvar cumulativeDistanceToA = 0, cumulativeDistanceToB = 0;\n\t\tfor (var i = 0; cumulativeDistanceToB < ratioDist; i++) {\n\t\t\tvar pointA = latLngs[i], pointB = latLngs[i+1];\n\n\t\t\tcumulativeDistanceToA = cumulativeDistanceToB;\n\t\t\tcumulativeDistanceToB += pointA.distanceToNextPoint;\n\t\t}\n\n\t\tif (pointA == undefined && pointB == undefined) { // Happens when line has no length\n\t\t\tvar pointA = latLngs[0], pointB = latLngs[1], i = 1;\n\t\t}\n\n\t\t// compute the ratio relative to the segment [ab]\n\t\tvar segmentRatio = ((cumulativeDistanceToB - cumulativeDistanceToA) !== 0) ? ((ratioDist - cumulativeDistanceToA) / (cumulativeDistanceToB - cumulativeDistanceToA)) : 0;\n\t\tvar interpolatedPoint = this.interpolateOnLatLngSegment(pointA, pointB, segmentRatio);\n\t\tvar traveledPath = latLngs.slice(0, i);\n\t\ttraveledPath.push(interpolatedPoint);\n\t\treturn {\n\t\t\ttraveledPath: traveledPath,\n\t\t\tlatLng: interpolatedPoint\n\t\t};\n\t},\n\n /**\n Returns the Point located on a segment at the specified ratio of the segment length.\n @param {L.Point} pA coordinates of point A\n @param {L.Point} pB coordinates of point B\n @param {Number} the length ratio, expressed as a decimal between 0 and 1, inclusive.\n @returns {L.Point} the interpolated point.\n */\n interpolateOnPointSegment: function (pA, pB, ratio) {\n return L.point(\n (pA.x * (1 - ratio)) + (ratio * pB.x),\n (pA.y * (1 - ratio)) + (ratio * pB.y)\n );\n },\n\n /**\n Returns the LatLng located on a segment at the specified ratio of the segment length.\n @param {L.LatLng} pA coordinates of LatLng A\n @param {L.LatLng} pB coordinates of LatLng B\n @param {Number} the length ratio, expressed as a decimal between 0 and 1, inclusive.\n @returns {L.LatLng} the interpolated LatLng.\n */\n interpolateOnLatLngSegment: function (pA, pB, ratio) {\n return L.latLng(\n (pA.lat * (1 - ratio)) + (ratio * pB.lat),\n (pA.lng * (1 - ratio)) + (ratio * pB.lng)\n );\n },\n\n\t/**\n\t\t@param {L.Map} map Leaflet map to be calculate distances\n @param {LatLng[]} linePoints of coordinates\n @return {Number} distance in meter\n */\n\tdistance: function(map, linePoints){\n\t\tvar distanceInMeter = 0;\n for (var i = 1; i < linePoints.length; i++) {\n distanceInMeter += map.distance(linePoints[i], linePoints[i - 1]);\n }\n\n return distanceInMeter;\n\t},\n\n\t/**\n\t\t@param {L.Map} map Leaflet map to be calculate distances\n @param {LatLng[]} collection of coordinates\n @param {Number} speed in KM/H\n @return {Number} duration in ms\n */\n\tgetDuration: function (map, collection, speed) {\n\t\tvar distance = L.Motion.Utils.distance(map, collection.map(function(m){ return L.Motion.Utils.toLatLng(m); })); // in meters;\n\t\treturn distance/(speed/3600); // m / (km/h * 1000 => m/h / (60 * 60)) => m / k/s (m/s * 1000) => 1000 * m / m/s => ms;\n\t},\n\n\ttoLatLng: function(a, b, c) {\n\t\tif (a instanceof L.LatLng) {\n\t\t\treturn a;\n\t\t}\n\t\tif (L.Util.isArray(a) && typeof a[0] !== 'object') {\n\t\t\tif (a.length === 3) {\n\t\t\t\treturn L.latLng(a[0], a[1], a[2]);\n\t\t\t}\n\t\t\tif (a.length === 2) {\n\t\t\t\treturn L.latLng(a[0], a[1]);\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\tif (a === undefined || a === null) {\n\t\t\treturn a;\n\t\t}\n\t\tif (typeof a === 'object' && 'lat' in a) {\n\t\t\treturn L.latLng(a.lat, 'lng' in a ? a.lng : a.lon, a.alt);\n\t\t}\n\t\tif (b === undefined) {\n\t\t\treturn null;\n\t\t}\n\t\treturn L.latLng(a, b, c);\n\t},\n\n\tgetAngle: function(prevPoint, nextPoint) {\n\t\tvar angle = Math.atan2(nextPoint.lat - prevPoint.lat, nextPoint.lng - prevPoint.lng) * 180 / Math.PI;\n\t\tif (angle < 0) {\n\t\t\tangle += 360;\n\t\t}\n\n\t\treturn angle;\n\t},\n\n\t// Leaflet -> geometries -> LineUtil\n\tisFlat: function (latlngs) {\n\t\treturn !L.Util.isArray(latlngs[0]) || (typeof latlngs[0][0] !== 'object' && typeof latlngs[0][0] !== 'undefined');\n\t}\n};\n\n\n//# sourceURL=webpack://leaflet.motion/./src/leaflet.motion.utils.js?"); /***/ }) -/******/ }); \ No newline at end of file +/******/ }); +/************************************************************************/ +/******/ +/******/ // startup +/******/ // Load entry module and return exports +/******/ // This entry module can't be inlined because the eval devtool is used. +/******/ __webpack_modules__["./src/leaflet.motion.js"](); +/******/ __webpack_modules__["./src/leaflet.motion.utils.js"](); +/******/ __webpack_modules__["./src/leaflet.motion.easing.js"](); +/******/ __webpack_modules__["./src/layer/leaflet.motion.polyline.js"](); +/******/ __webpack_modules__["./src/layer/leaflet.motion.polygon.js"](); +/******/ __webpack_modules__["./src/layer/leaflet.motion.group.js"](); +/******/ var __webpack_exports__ = {}; +/******/ __webpack_modules__["./src/layer/leaflet.motion.seq.js"](); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/dist/leaflet.motion.min.js b/dist/leaflet.motion.min.js index 22777bb..77f9092 100644 --- a/dist/leaflet.motion.min.js +++ b/dist/leaflet.motion.min.js @@ -1,9 +1,2 @@ -/*! - * - * leaflet.motion - v0.3.2 (https://github.com/Igor-Vladyka/leaflet.motion#readme) - * Animation plugin for Leaflet.js - * - * MIT (http://www.opensource.org/licenses/mit-license.php) - * (c) 2022 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),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),i&&(this.motionOptions=L.Util.extend({},this.motionOptions,i)),e&&(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){return 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&&Array.from(this.__marker._icon.children).forEach((function(t){var n=t.getAttribute("motion-base");n&&(t.style.transform="rotate("+n+"deg)")}))),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);this.setLatLngs(e.traveledPath),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];i.lat===e.lat&&i.lng===e.lng?(n.addTo(this._map),n.addEventParent(this)):n._icon&&n._icon.children.length&&Array.from(n._icon.children).forEach((function(n){var e=n.getAttribute("motion-base");if(e){var o=0;e&&!isNaN(+e)&&(o=+e),n.style.transform="rotate(-"+Math.round(L.Motion.Utils.getAngle(i,t)+o)+"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._map,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._map,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){var n=this.motionSpeed.duration;return this.motionOptions.duration=t||0,this.animation&&n&&(this.motionPause(),this.__ellapsedTime=this.__ellapsedTime*(n/t),this.motionOptions.duration=t,this.motionResume()),this},motionSpeed:function(t){var n=this.motionOptions.speed;return this.motionOptions.speed=t||0,this.animation&&n&&(this.motionPause(),this.__ellapsedTime=this.__ellapsedTime*(n/t),this.motionOptions.duration=L.Motion.Utils.getDuration(this._map,this._linePoints,this.motionOptions.speed),this.motionResume()),this},getMarker:function(){return this.__marker},getMarkers:function(){return[this.getMarker()]}}},function(t,n){L.Motion.Utils={attachDistances:function(t,n){if(n.length>1)for(var i=1;io?n[o].motionStart():this.motionStop(!0)},__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 +/*! For license information please see leaflet.motion.min.js.LICENSE.txt */ +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),i&&(this.motionOptions=L.Util.extend({},this.motionOptions,i)),e&&(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){return 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&&Array.from(this.__marker._icon.children).forEach((function(t){var n=t.getAttribute("motion-base");n&&(t.style.transform="rotate("+n+"deg)")}))),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);this.setLatLngs(e.traveledPath),this._drawMarker(e.latLng),this.options.onTick&&this.options.onTick.bind(this)(nextPoint),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];i.lat===e.lat&&i.lng===e.lng?(n.addTo(this._map),n.addEventParent(this)):n._icon&&n._icon.children.length&&Array.from(n._icon.children).forEach((function(n){var e=n.getAttribute("motion-base");if(e){var o=0;e&&!isNaN(+e)&&(o=+e);const s=-1*Math.round(L.Motion.Utils.getAngle(i,t)+o);n.style.transform=`rotate(${s}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._map,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._drawMarker(this._linePoints[this._linePoints.length-1]),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._map,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){var n=this.motionSpeed.duration;return this.motionOptions.duration=t||0,this.animation&&n&&(this.motionPause(),this.__ellapsedTime=this.__ellapsedTime*(n/t),this.motionOptions.duration=t,this.motionResume()),this},motionSpeed:function(t){var n=this.motionOptions.speed;return this.motionOptions.speed=t||0,this.animation&&n&&(this.motionPause(),this.__ellapsedTime=this.__ellapsedTime*(n/t),this.motionOptions.duration=L.Motion.Utils.getDuration(this._map,this._linePoints,this.motionOptions.speed),this.motionResume()),this},getMarker:function(){return this.__marker},getMarkers:function(){return[this.getMarker()]}},L.Motion.Utils={attachDistances:function(t,n){if(n.length>1)for(var i=1;io?n[o].motionStart():this.motionStop(!0)},__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/dist/leaflet.motion.min.js.LICENSE.txt b/dist/leaflet.motion.min.js.LICENSE.txt index a6dc042..900f58c 100644 --- a/dist/leaflet.motion.min.js.LICENSE.txt +++ b/dist/leaflet.motion.min.js.LICENSE.txt @@ -1,9 +1,9 @@ /*! * - * leaflet.motion - v0.2.4 (https://github.com/Igor-Vladyka/leaflet.motion#readme) + * leaflet.motion - v0.3.2 (https://github.com/Igor-Vladyka/leaflet.motion#readme) * Animation plugin for Leaflet.js * * MIT (http://www.opensource.org/licenses/mit-license.php) - * (c) 2021 Igor Vladyka (https://github.com/Igor-Vladyka/) + * (c) 2025 Igor Vladyka (https://github.com/Igor-Vladyka/) * */ diff --git a/src/leaflet.motion.js b/src/leaflet.motion.js index 1a62273..26bff03 100644 --- a/src/leaflet.motion.js +++ b/src/leaflet.motion.js @@ -221,6 +221,7 @@ L.Motion.Animate = { motionStop: function (animEnded) { this.motionPause(); this.setLatLngs(this._linePoints); + this._drawMarker(this._linePoints[this._linePoints.length - 1]); this.__ellapsedTime = null; this._removeMarker(animEnded); this.fire(L.Motion.Event.Ended, {layer: this}, false);