{"version":3,"sources":["assets/js/bouncemarker.js"],"names":["originalOnAdd","L","Marker","prototype","onAdd","originalOnRemove","onRemove","mergeOptions","bounceOnAdd","bounceOnAddOptions","duration","height","loop","bounceOnAddCallback","include","_toPoint","latlng","_map","latLngToContainerPoint","_toLatLng","point","containerPointToLatLng","_motionStep","opts","self","progress","Date","start","delta","_easeOutBounce","step","_animationId","Util","requestAnimFrame","timestamp","end","_bounceMotion","callback","original","latLng","_origLatlng","start_y","_dropPoint","y","start_x","x","distance","_point","project","getCenter","_origMapCenter","setLatLng","pos","bounce","options","endCallback","arguments","_getDropPoint","stopBounce","cancelAnimFrame","top_y","undefined","getBounds","_northEast","Point","map","call","getLatLng"],"mappings":";CA2BA,WAEMA,IAAAA,EAAgBC,EAAEC,OAAOC,UAAUC,MACnCC,EAAmBJ,EAAEC,OAAOC,UAAUG,SAG1CL,EAAEC,OAAOK,aAAa,CACpBC,aAAa,EACbC,mBAAoB,CAClBC,SAAU,IACVC,QAAS,EACTC,KAAM,GAERC,oBAAqB,eAGvBZ,EAAEC,OAAOY,QAAQ,CAEfC,SAAU,SAASC,GACV,OAAA,KAAKC,KAAKC,uBAAuBF,IAG1CG,UAAW,SAASC,GACX,OAAA,KAAKH,KAAKI,uBAAuBD,IAG1CE,YAAa,SAASC,GAChBC,IAAAA,EAAO,KAEPC,GADa,IAAIC,KAASH,EAAKI,OACPJ,EAAKb,SAE7Be,EAAW,IACbA,EAAW,GAGTG,IAAAA,EAAQJ,EAAKK,eAAeJ,GAChCF,EAAKO,KAAKF,GAEO,IAAbH,IACFF,EAAKI,MAAQ,IAAID,KACjBD,EAAW,EACPF,EAAKX,KAAO,IAAGW,EAAKX,KAAOW,EAAKX,KAAO,GACzB,IAAdW,EAAKX,MAMXY,EAAKO,aAAe9B,EAAE+B,KAAKC,iBAAiB,SAASC,GACnDV,EAAKF,YAAYC,KANfA,EAAKY,OAUXC,cAAe,SAASb,EAAMc,GACxBC,IAAAA,EAAWrC,EAAEsC,OAAO,K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KAAK2B,gBAAgB,KAAK5B,eAK9B0B,cAAe,SAAS9C,GAGlBiD,IAAAA,EAMG,OAPFb,KAAAA,OAAS,KAAKhC,SAAS,KAAKyB,aAG/BoB,OADaC,IAAXlD,GAAwBA,EAAS,EAC3B,KAAKI,SAAS,KAAKE,KAAK6C,YAAYC,YAAYpB,EAEhD,KAAKI,OAAOJ,EAAIhC,EAEnB,IAAIV,EAAE+D,MAAM,KAAKjB,OAAOF,EAAGe,IAGpCxD,MAAO,SAAS6D,GACThD,KAAAA,KAAOgD,EAGZjE,EAAckE,KAAK,KAAMD,GAGpBzB,KAAAA,YAAc,KAAK2B,aAES,IAA7B,KAAKb,QAAQ9C,aACV6C,KAAAA,OAAO,KAAKC,QAAQ7C,mBAAoB,KAAK6C,QAAQzC,sBAI9DP,SAAU,SAAS2D,GACZP,KAAAA,aACLrD,EAAiB6D,KAAK,KAAMD,MA1JlC","file":"bouncemarker.102d5cb6.js","sourceRoot":"..","sourcesContent":["/**\n * Copyright (C) 2013 Maxime Hadjinlian \n * All Rights Reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * - Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * - Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\n(function() {\n // Retain the value of the original onAdd and onRemove functions\n let originalOnAdd = L.Marker.prototype.onAdd;\n let originalOnRemove = L.Marker.prototype.onRemove;\n\n // Add bounceonAdd options\n L.Marker.mergeOptions({\n bounceOnAdd: false,\n bounceOnAddOptions: {\n duration: 1000,\n height: -1,\n loop: 1,\n },\n bounceOnAddCallback: function() {},\n });\n\n L.Marker.include({\n\n _toPoint: function(latlng) {\n return this._map.latLngToContainerPoint(latlng);\n },\n\n _toLatLng: function(point) {\n return this._map.containerPointToLatLng(point);\n },\n\n _motionStep: function(opts) {\n let self = this;\n let timePassed = new Date() - opts.start;\n let progress = timePassed / opts.duration;\n\n if (progress > 1) {\n progress = 1;\n }\n\n let delta = self._easeOutBounce(progress);\n opts.step(delta);\n\n if (progress === 1) {\n opts.start = new Date();\n progress = 0;\n if (opts.loop > 0) opts.loop = opts.loop - 1;\n if (opts.loop === 0) {\n opts.end();\n return;\n }\n }\n\n self._animationId = L.Util.requestAnimFrame(function(timestamp) {\n self._motionStep(opts);\n });\n },\n\n _bounceMotion: function(opts, callback) {\n let original = L.latLng(this._origLatlng);\n let start_y = this._dropPoint.y;\n let start_x = this._dropPoint.x;\n let distance = this._point.y - start_y;\n let self = this;\n\n self._animationId = L.Util.requestAnimFrame(function() {\n self._motionStep({\n duration: opts.duration || 1000, // 1 sec by default\n loop: opts.loop || 1,\n start: new Date(),\n step: function(delta) {\n self._dropPoint.y =\n start_y\n + (distance * delta)\n - (self._map.project(self._map.getCenter()).y - self._origMapCenter.y);\n self._dropPoint.x =\n start_x\n - (self._map.project(self._map.getCenter()).x - self._origMapCenter.x);\n self.setLatLng(self._toLatLng(self._dropPoint));\n },\n end: function() {\n self.setLatLng(original);\n if (typeof callback === 'function') callback();\n },\n });\n });\n },\n\n // Many thanks to Robert Penner for this function\n _easeOutBounce: function(pos) {\n if ((pos) < (1 / 2.75)) {\n return (7.5625 * pos * pos);\n } else if (pos < (2 / 2.75)) {\n return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);\n } else if (pos < (2.5 / 2.75)) {\n return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);\n } else {\n return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);\n }\n },\n\n // Bounce : if options.height in pixels is not specified, drop from top.\n // If options.duration is not specified animation is 1s long.\n bounce: function(options, endCallback) {\n if (typeof options === 'function') {\n endCallback = options;\n options = null;\n }\n options = options || {duration: 1000, height: -1, loop: 1};\n\n // backward compatibility\n if (typeof options === 'number') {\n options.duration = arguments[0];\n options.height = arguments[1];\n }\n\n // Keep original map center\n this._origMapCenter = this._map.project(this._map.getCenter());\n this._dropPoint = this._getDropPoint(options.height);\n this._bounceMotion(options, endCallback);\n },\n\n stopBounce: function(){\n // We may have modified the marker; so we need to place it where it\n // belongs so next time its coordinates are not changed.\n this.setLatLng(this._origLatlng);\n L.Util.cancelAnimFrame(this._animationId);\n },\n\n // This will get you a drop point given a height.\n // If no height is given, the top y will be used.\n _getDropPoint: function(height) {\n // Get current coordidates in pixel\n this._point = this._toPoint(this._origLatlng);\n let top_y;\n if (height === undefined || height < 0) {\n top_y = this._toPoint(this._map.getBounds()._northEast).y;\n } else {\n top_y = this._point.y - height;\n }\n return new L.Point(this._point.x, top_y);\n },\n\n onAdd: function(map) {\n this._map = map;\n\n // Call leaflet original method to add the Marker to the map.\n originalOnAdd.call(this, map);\n\n // Keep original latitude and longitude\n this._origLatlng = this.getLatLng();\n\n if (this.options.bounceOnAdd === true) {\n this.bounce(this.options.bounceOnAddOptions, this.options.bounceOnAddCallback);\n }\n },\n\n onRemove: function(map) {\n this.stopBounce();\n originalOnRemove.call(this, map);\n },\n });\n})();\n"]}