You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
27 KiB

5 years ago
/*! Snowflakes | © 2018 Denis Seleznev | MIT License | https://github.com/hcodes/snowflakes/ */
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?module.exports=a():"function"==typeof define&&define.amd?define(a):e.Snowflakes=a()}(this,function(){"use strict";function h(e,a){if(!(e instanceof a))throw new TypeError("Cannot call a class as a function")}function n(e,a){for(var t=0;t<a.length;t++){var n=a[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function e(e,a,t){return a&&n(e.prototype,a),t&&n(e,t),e}function o(e,a){return function(e){if(Array.isArray(e))return e}(e)||function(e,a){var t=[],n=!0,l=!1,i=void 0;try{for(var o,r=e[Symbol.iterator]();!(n=(o=r.next()).done)&&(t.push(o.value),!a||t.length!==a);n=!0);}catch(e){l=!0,i=e}finally{try{n||null==r.return||r.return()}finally{if(l)throw i}}return t}(e,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var l="";function m(t,n){Object.keys(n).forEach(function(e){var a=e;l&&-1<e.search("animation")&&(a=l+e[0].toUpperCase()+e.substr(1)),t.style[a]=n[e]})}function c(e,a){return e+Math.floor(Math.random()*(a-e))}function f(e,a,t,n,l){return n+(l-n)*(e-a)/(t-a)}"undefined"!=typeof window&&(l=-1<Array.prototype.slice.call(window.getComputedStyle(document.documentElement,"")).join(",").search(/,animation/)?"":"Webkit");var a,t,i,r=function(){function s(e,a,t){h(this,s);var n=t.minSize===t.maxSize;this.innerSize=n?0:c(0,s.maxInnerSize),this.size=s.calcSize(this.innerSize,t);var l=document.createElement("div"),i=document.createElement("div"),o=this.getAnimationProps(a,t),r={animationDelay:o.animationDelay,animationDuration:o.animationDuration,left:99*Math.random()+"%",marginTop:-Math.sqrt(2)*this.size+"px",width:this.size+"px",height:this.size+"px"};n||(r.zIndex=t.zIndex+10*this.size,r.opacity=f(this.size,t.minSize,t.maxSize,t.minOpacity,t.maxOpacity)),m(l,r),m(i,{animationName:"snowflake_x_"+this.innerSize,animationDelay:Math.random()+"s"}),l.classList.add("snowflake"),i.classList.add("snowflake__inner"),t.types&&i.classList.add("snowflake__inner_type_"+c(0,t.types)),t.wind&&i.classList.add("snowflake__inner_wind"),t.rotation&&i.classList.add("snowflake__inner_rotation"+(.5<Math.random()?"":"_reverse")),l.appendChild(i),this._elem=l,e.appendChild(l)}return e(s,[{key:"getAnimationProps",value:function(e,a){var t=e/50/a.speed,n=t/3;return{animationDelay:Math.random()*t+"s",animationDuration:f(this.size,a.minSize,a.maxSize,t,n)+"s"}}},{key:"resize",value:function(e,a){var t=this.getAnimationProps(e,a);m(this._elem,t)}},{key:"destroy",value:function(){delete this._elem}}],[{key:"calcSize",value:function(e,a){return Math.floor(f(e,0,s.maxInnerSize,a.minSize,a.maxSize))}}]),s}();i=20,(t="maxInnerSize")in(a=r)?Object.defineProperty(a,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):a[t]=i;var s='.snowflake__inner_type_0:before{background-image:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2236.283%22%20height%3D%2236.283%22%3E%3Cpath%20d%3D%22M35.531%2017.391h-3.09l.845-1.464a.748.748%200%201%200-1.297-.75l-1.276%202.214H28.61l2.515-4.354a.751.751%200%200%200-.272-1.024.75.75%200%200%200-1.024.274l-2.948%205.104h-2.023a6.751%206.751%200%200%200-2.713-4.684l1.019-1.76%205.896-.002a.75.75%200%200%200%200-1.5l-5.029.002%201.051-1.82%202.557.002a.75.75%200%200%200%200-1.5l-1.689-.002%201.545-2.676a.75.75%200%201%200-1.302-.75l-1.547%202.676-.844-1.463a.749.749%200%201%200-1.297.75l1.278%202.213-1.051%201.818-2.514-4.354a.75.75%200%200%200-1.298.75l2.946%205.104-1.016%201.758a6.692%206.692%200%200%200-2.706-.57%206.74%206.74%200%200%200-2.707.568l-1.013-1.754%202.946-5.105a.75.75%200%200%200-1.298-.75L13.56%208.697l-1.05-1.818%201.278-2.217a.749.749%200%200%200-1.298-.75l-.845%201.465-1.551-2.678a.75.75%200%200%200-1.024-.273.748.748%200%200%200-.274%201.023l1.545%202.678H8.652a.75.75%200%200%200%200%201.5h2.556l1.05%201.818H7.231a.75.75%200%200%200%200%201.5h5.894l1.017%201.762a6.755%206.755%200%200%200-2.712%204.684H9.406l-2.95-5.104a.75.75%200%201%200-1.299.75l2.516%204.354H5.569l-1.277-2.213a.75.7