2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
!function(y){"use strict";function o(n,t){(null==t||t>n.length)&&(t=n.length);for(var i=0,o=Array(t);i<t;i++)o[i]=n[i];return o}function e(n,t,i){if("function"==typeof n?n===t:n.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function r(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}function k(n,t){return n.get(e(n,t))}function a(n,t,i){(function(n,t){if(t.has(n))throw new TypeError("Cannot initialize the same private elements twice on an object")})(n,t),t.set(n,i)}function s(n,t,i){return n.set(e(n,t),i),i}function c(n,t){for(var i=0;i<t.length;i++){var o=t[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(n,h(o.key),o)}}function n(n,t,i){return t&&c(n.prototype,t),i&&c(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n}function u(n,t,i){return(t=h(t))in n?Object.defineProperty(n,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[t]=i,n}function b(n,t){return function(n){if(Array.isArray(n))return n}(n)||function(n,t){var i=null==n?null:"undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(null!=i){var o,e,r,a,s=[],c=!0,u=!1;try{if(r=(i=i.call(n)).next,0!==t)for(;!(c=(o=r.call(i)).done)&&(s.push(o.value),s.length!==t);c=!0);}catch(n){u=!0,e=n}finally{try{if(!c&&null!=i.return&&(a=i.return(),Object(a)!==a))return}finally{if(u)throw e}}return s}}(n,t)||function(n,t){if(n){if("string"==typeof n)return o(n,t);var i={}.toString.call(n).slice(8,-1);return"Object"===i&&n.constructor&&(i=n.constructor.name),"Map"===i||"Set"===i?Array.from(n):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?o(n,t):void 0}}(n,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(n){var t=function(n,t){if("object"!=typeof n||!n)return n;var i=n[Symbol.toPrimitive];if(void 0===i)return String(n);var o=i.call(n,t);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}(n,"string");return"symbol"==typeof t?t:t+""}var i=function(){function t(n){r(this,t),u(this,"bounceHeight",15),u(this,"contractHeight",12),u(this,"bounceSpeed",52),u(this,"contractSpeed",52),u(this,"shadowAngle",-Math.PI/4),u(this,"elastic",!0),u(this,"exclusive",!1),u(this,"immediateStop",!1),n&&Object.assign(this,n)}return n(t,[{key:"override",value:function(n){return Object.assign(new t(this),n)}}])}(),l=new WeakMap,t=function(){return n(function n(){r(this,n),a(this,l,[])},[{key:"getBouncingMarkers",value:function(){return k(l,this)}},{key:"addBouncingMarker",value:function(n,t){t||n._bouncingMotion.bouncingOptions.exclusive?this.stopAllBouncingMarkers():this.stopExclusiveMarkerBouncing(),k(l,this).push(n)}},{key:"stopExclusiveMarkerBouncing",value:function(){var n=k(l,this).find(function(n){return n._bouncingMotion.bouncingOptions.exclusive});n&&n.stopBouncing()}},{key:"removeBouncingMarker",value:function(n){var t=k(l,this).indexOf(n);~t&&k(l,this).splice(t,1)}},{key:"stopAllBouncingMarkers",value:function(n){for(var t,i=0<arguments.length&&void 0!==n&&n;t=k(l,this).shift();)t.stopBouncing(i)}}])}();!function(n,t){void 0===t&&(t={});var i,o,e=t.insertAt;"undefined"!=typeof document&&(i=document.head||document.getElementsByTagName("head")[0],(o=document.createElement("style")).type="text/css","top"===e&&i.firstChild?i.insertBefore(o,i.firstChild):i.appendChild(o),o.styleSheet?o.styleSheet.cssText=n:o.appendChild(document.createTextNode(n)))}("@keyframes l-smooth-marker-bouncing-move {\n from {\n transform: translate(var(--pos-x), var(--pos-y))\n }\n to {\n transform: translate(var(--pos-x-jump, var(--pos-x)), var(--pos-y-jump))\n }\n}\n\n@keyframes l-smooth-marker-bouncing-contract {\n from {\n transform: translate(var(--pos-x), var(--pos-y))\n }\n to {\n transform: translate(var(--pos-x), var(--pos-y-contract)) scaleY(var(--scale-contract))\n }\n}\n\n.bouncing {\n animation-name: l-smooth-marker-bouncing-move, l-smooth-marker-bouncing-move, l-smooth-marker-bouncing-contract, l-smooth-marker-bouncing-contract;\n animation-direction: normal, reverse, normal, reverse;\n animation-duration: var(--duration-jump), var(--duration-jump), var(--duration-contract), var(--duration-contract);\n animation-delay: var(--delays)\n}\n\n.bouncing.simple {\n animation-name: l-smooth-marker-bouncing-move, l-smooth-marker-bouncing-move;\n animation-direction: normal, reverse;\n animation-duration: var(--duration-jump), var(--duration-jump);\n animation-delay: var(--delays)\n}\n");var m=/([\w-]+): ([^;]+);/g,M=function(){function o(n){r(this,o),n&&Object.assign(this,n)}return n(o,[{key:"findOpacity",value:function(n){this.opacity=(null==n?void 0:n.opacityWhenUnclustered)||(null==n?void 0:n.opacity)||1}},{key:"withStyles",value:function(n){var t=new o(this);return t&&Object.assign(t,n),t}},{key:"toString",value:function(){return Object.entries(this).map(function(n){return"".concat(n[0],": ").concat(n[1],";")}).join(" ")}}],[{key:"parse",value:function(n){for(var t={},i=m.exec(n);i;)t[i[1]]=i[2],i=m.exec(n);return delete t["z-index"],delete t.opacity,t.outline="none",new o(t)}},{key:"ofMarker",value:function(n){var t=o.parse(n._icon.style.cssText);return t.findOpacity(n.options),t["z-index"]=n._zIndex,t}}])}(),p="l-smooth-marker-bouncing-",d=p+"contract";function _(t,n){n.forEach(function(n){return y.DomUtil.removeClass(t,n)}),t.offsetWidth,n.forEach(function(n){return y.DomUtil.addClass(t,n)})}var v,f,g,w,S,B=new WeakMap,O=new WeakMap,x=new WeakMap,j=new WeakMap,A=new WeakMap,E=function(){function g(n,t,i){var o=this;r(this,g),u(this,"marker",void 0),u(this,"position",void 0),u(this,"bouncingOptions",void 0),u(this,"isBouncing",!1),u(this,"iconStyles",void 0),u(this,"shadowStyles",void 0),u(this,"bouncingAnimationPlaying",!1),u(this,"onMotionEnd",void 0),a(this,B,d),a(this,O,["bouncing"]),a(this,x,void 0),a(this,j,void 0),a(this,A,function(n){return o.onAnimationEnd(n)}),this.marker=n,this.position=t,this.updateBouncingOptions(i)}return n(g,[{key:"updateBouncingOptions",value:function(n){var t;this.bouncingOptions=n instanceof i?n:this.bouncingOptions.override(n),this.bouncingOptions.elastic&&this.bouncingOptions.contractHeight?(s(B,this,d),-1<(t=k(O,this).indexOf("simple"))&&k(O,this).splice(t,1),this.marker._icon&&y.DomUtil.removeClass(this.marker._icon,"simple")):(s(B,this,"l-smooth-marker-bouncing-move"),k(O,this).push("simple")),this.marker._icon&&this.resetStyles(this.marker)}},{key:"onAnimationEnd",value:function(n){var t,i;n.animationName===k(B,this)&&(s(x,this,(t=k(x,this),++t)),s(x,this,k(x,this)%2),k(x,this)||(this.isBouncing&&(null===k(j,this)||s(j,this,(i=k(j,this),--i)))?(_(this.marker._icon,k(O,this)),this.marker._shadow&&this.bouncingOptions.shadowAngle&&_(this.marker._shadow,k(O,this))):this._stopBouncingAnimation()))}},{key:"resetStyles",value:function(n){var t,i,o=this;this.marker=n,this.iconStyles=M.ofMarker(n),n._shadow&&(this.shadowStyles=M.parse(n._shadow.style.cssText));var e=(null===(t=this.marker.getIcon())||void 0===t||null===(t=t.options)||void 0===t?void 0:t.iconSize[1])||(null===(i=this.marker)||void 0===i||null===(i=i._iconObj)||void 0===i||null===(i=i.options)||void 0===i?void 0:i.iconSize[1]),r=g.animationParams(this.position,this.bouncingOptions,e);this.iconStyles=this.iconStyles.withStyles(r),this.marker._icon.style.cssText=this.iconStyles.toString(),this.bouncingAnimationPlaying&&(_(this.marker._icon,k(O,this)),this.marker._icon.addEventListener("animationend",k(A,this)));var a,s,c,u,h,l,m,p=this.bouncingOptions,d=p.bounceHeight,v=p.contractHeight,f=p.shadowAngle;this.marker._shadow&&(f?(u=(c=b(function(n,t,i,o){for(var e,r=Math.round(n+Math.cos(i)*(2*o)),a=Math.round(t+Math.sin(i)*(2*o)),s=Math.abs(r-n),c=n<r?1:-1,u=Math.abs(a-t),h=t<a?1:-1,l=(u<s?s:-u)/2,m=[],p=0;m.push([n,t]),++p!==o;)-s<(e=l)&&(l-=u,n+=c),e<u&&(l+=s,t+=h);return m}((s=this.position).x,s.y,f,d+1)[d],2))[0],h=c[1],l=null===(a=this.marker.getIcon())||void 0===a||null===(a=a.options)||void 0===a?void 0:a.shadowSize[1],m=g.contractScale(l,v),this.shadowStyles=this.shadowStyles.withStyles(r).withStyles({"--pos-x-jump":"".concat(u,"px"),"--pos-y-jump":"".concat(h,"px"),"--scale-contract":m}),this.marker._shadow.style.cssText=this.shadowStyles.toString(),this.bouncingAnimationPlaying&&_(this.marker._shadow,k(O,this))):k(O,this).forEach(function(n){y.DomUtil.removeClass(o.marker._shadow,n)}))}},{key:"bounce",value:function(n){s(j,this,0<arguments.length&&void 0!==n?n:null),this.isBouncing=!0,this.bouncingAnimationPlaying||(s(x,this,0),this.bouncingAnimationPlaying=!0,_(this.marker._icon,k(O,this)),this.marker._shadow&&this.bouncingOptions.shadowAngle&&_(this.marker._shadow,k(O,this)),this.marker._icon.addEventListener("animationend",k(A,this)))}},{key:"stopBouncing",value:function(n){var t=0<arguments.length&&void 0!==n&&n;this.isBouncing=!1,(t=t||this.bouncingOptions.immediateStop)&&this._stopBouncingAnimation()}},{key:"_stopBouncingAnimation",value:function(){var t=this;k(O,this).forEach(function(n){y.DomUtil.removeClass(t.marker._icon,n),t.marker._shadow&&y.DomUtil.removeClass(t.marker._shadow,n)}),this.bouncingAnimationPlaying=!1,this.onMotionEnd&&(this.onMotionEnd(),this.onMotionEnd=null),this.marker.fire("bounceend")}}],[{key:"animationParams",value:function(n,t,i){var o=n.x,e=n.y,r=t.bounceHeight,a=t.contractHeight,s=t.bounceSpeed,c=t.contractSpeed,u=g.contractScale(i,a),h=g.calculateDuration(r,s),l=g.calculateDuration(a,c),m=[0,h,2*h,2*h+l];return{"--pos-x":"".concat(o,"px"),"--pos-y":"".concat(e,"px"),"--pos-y-jump":"".concat(e-r,"px"),"--pos-y-contract":"".concat(e+a,"px"),"--scale-contract":u,"--duration-jump":"".concat(h,"ms"),"--duration-contract":"".concat(l,"ms"),"--delays":"0ms, ".concat(m[1],"ms, ").concat(m[2],"ms, ").concat(m[3],"ms")}}},{key:"contractScale",value:function(n,t){return(n-t)/n}},{key:"calculateDuration",value:function(n,t){if(0===n)return 0;for(var i=Math.round(.8*t),o=n;--o;)i+=Math.round(t/(n-o));return i}}])}();(v=y).Marker.include((g=(f=v).Marker.prototype._setPos,w=f.Marker.prototype.onAdd,S=f.Marker.prototype.setIcon,{_bouncingOptions:new i,_orchestration:new t,_realMarker:!0,setBouncingOptions:function(n){return this._bouncingMotion.updateBouncingOptions(n),this},isBouncing:function(){return this._bouncingMotion.isBouncing},bounce:function(n){var t=this,i=0<arguments.length&&void 0!==n?n:null;i&&(this._bouncingMotion.onMotionEnd=function(){f.Marker.prototype._orchestration.removeBouncingMarker(t)}),this._bouncingMotion.bounce(i);var o=this._bouncingMotion.bouncingOptions.exclusive;return f.Marker.prototype._orchestration.addBouncingMarker(this,o),this},stopBouncing:function(n){var t=0<arguments.length&&void 0!==n&&n;return this._bouncingMotion.stopBouncing(t),f.Marker.prototype._orchestration.removeBouncingMarker(this),this},toggleBouncing:function(){return this._bouncingMotion.isBouncing?this.stopBouncing():this.bounce(),this},isRealMarker:function(){return Object.hasOwn(this.__proto__,"_realMarker")},_setPos:function(n){g.call(this,n),this.isRealMarker()&&(this._bouncingMotion.position=n,this._bouncingMotion.resetStyles(this))},onAdd:function(n){w.call(this,n),this.isRealMarker()&&this._bouncingMotion.resetStyles(this)},setIcon:function(n){S.call(this,n),this.isRealMarker()&&this._icon&&this._bouncingMotion.resetStyles(this)}})),v.Marker.setBouncingOptions=function(n){v.Marker.prototype._bouncingOptions=n instanceof i?n:new i(n)},v.Marker.getBouncingMarkers=function(){return v.Marker.prototype._orchestration.getBouncingMarkers()},v.Marker.stopAllBouncingMarkers=function(){var n=0<arguments.length&&void 0!==arguments[0]&&arguments[0];v.Marker.prototype._orchestration.stopAllBouncingMarkers(n)},v.Marker.addInitHook(function(){var n;this.isRealMarker()&&(n=new i(v.Marker.prototype._bouncingOptions),this._bouncingMotion=new E(this,new v.Point(0,0),n))})}(L);
|