mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-23 14:00:09 +00:00
2 lines
24 KiB
JavaScript
2 lines
24 KiB
JavaScript
|
/*! Snowflakes | © 2020 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=e||self).Snowflakes=a()}(this,function(){"use strict";function r(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 i(e,a){return function(e){if(Array.isArray(e))return e}(e)||function(e,a){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;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(e,a){if(!e)return;if("string"==typeof e)return l(e,a);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return l(e,a)}(e,a)||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 l(e,a){(null==a||a>e.length)&&(a=e.length);for(var t=0,n=new Array(a);t<a;t++)n[t]=e[t];return n}var o="";function s(t,n){Object.keys(n).forEach(function(e){var a=e;o&&-1<e.search("animation")&&(a=o+e[0].toUpperCase()+e.substr(1)),t.style[a]=n[e]})}function h(){var e,a=document.body,t=document.documentElement;return window.innerHeight?e=window.innerHeight:t&&t.clientHeight?e=t.clientHeight:a&&(e=a.clientHeight),e}function m(e,a){return a||(a=document.createElement("style"),document.body.appendChild(a)),a.styleSheet?a.styleSheet.cssText=e:"textContent"in a?a.textContent=e:a.innerHTML=e,a}function a(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function c(e,a){e.classList.add(a)}function f(e,a){return e+Math.floor(Math.random()*(a-e))}function u(e,a,t,n,l){return n+(l-n)*(e-a)/(t-a)}"undefined"!=typeof window&&(o=-1<Array.prototype.slice.call(window.getComputedStyle(document.documentElement,"")).join(",").search(/,animation/)?"":"Webkit");var t,v,d,_=function(){function o(e,a,t){r(this,o);var n=t.minSize===t.maxSize;this.innerSize=n?0:f(0,o.maxInnerSize),this.size=o.calcSize(this.innerSize,t);var l=document.createElement("div"),i=document.createElement("div"),a=this.getAnimationProps(a,t),a={animationDelay:a.animationDelay,animationDuration:a.animationDuration,left:99*Math.random()+"%",marginTop:-Math.sqrt(2)*this.size+"px",width:this.size+"px",height:this.size+"px"};n||(a.zIndex=t.zIndex+10*this.size,a.opacity=u(this.size,t.minSize,t.maxSize,t.minOpacity,t.maxOpacity)),s(l,a),s(i,{animationName:"snowflake_x_"+this.innerSize,animationDelay:Math.random()+"s"}),c(l,"snowflake"),c(i,"snowflake__inner"),t.types&&c(i,"snowflake__inner_type_"+f(0,t.types)),t.wind&&c(i,"snowflake__inner_wind"),t.rotation&&c(i,"snowflake__inner_rotation"+(.5<Math.random()?"":"_reverse")),l.appendChild(i),this._elem=l,e.appendChild(l)}return e(o,[{key:"getAnimationProps",value:function(e,a){var t=e/50/a.speed,e=t/3;return{animationDelay:Math.random()*t+"s",animationDuration:u(this.size,a.minSize,a.maxSize,t,e)+"s"}}},{key:"resize",value:function(e,a){a=this.getAnimationProps(e,a);s(this._elem,a)}},{key:"destroy",value:function(){delete this._elem}}],[{key:"calcSize",value:function(e,a){return Math.floor(u(e,0,o.maxInnerSize,a.minSize,a.maxSize))}}]),o}();d=20,(v="maxInnerSize")in(t=_)?Object.defineProperty(t,v,{value:d,enumerable:!0,configurable:!0,writable:!0}):t[v]=d;var w='.snowflake{position:absolute;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;pointer-events:none;-webkit-animation:snowflake_y 10s linear infinite;animation:snowflake_y 10s linear infinite;will-change:transform}.snowflake__inner,.snowflake__inner:before{position:absolute;top:0;right:0;
|