-
Notifications
You must be signed in to change notification settings - Fork 1
/
jz-bundle.js
7 lines (5 loc) · 3.04 KB
/
jz-bundle.js
1
2
3
4
5
6
7
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var _triangler=require("./triangler.js"),_triangler2=_interopRequireDefault(_triangler),triangler=new _triangler2.default;triangler.setup();
},{"./triangler.js":2}],2:[function(require,module,exports){
"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),svgns="http://www.w3.org/2000/svg",RED="rgb(212, 29, 0)",ORANGE="rgb(255, 147, 0)",YELLOW="rgb(255, 255, 0)",VIOLET="rgb(148, 33, 148)",TRIANGLE_INTERVAL=100,TRIANGLE_MAX_WIDTH=300,TRIANGLE_MIN_HEIGHT=50,TRIANGLE_MAX_HEIGHT=150,Triangler=function(){function t(){_classCallCheck(this,t),this.colors=[VIOLET,RED,ORANGE,YELLOW],this.bottomTriangleSpan=window.innerWidth,this.bottomTriangleIndex=0}return _createClass(t,[{key:"setup",value:function(){this.makeTopSvg(),this.makeBottomSvg()}},{key:"getRandomFromInterval",value:function(t,e){return Math.floor(Math.random()*(e-t+1))+t}},{key:"getRandomOpacityFromInterval",value:function(t,e){return Math.random()*(e-t)+t}},{key:"drawTriangle",value:function(t,e){var n=document.createElementNS(svgns,"polygon"),r=this.getRandomFromInterval(TRIANGLE_INTERVAL,TRIANGLE_MAX_WIDTH),o=this.getRandomFromInterval(TRIANGLE_MIN_HEIGHT,TRIANGLE_MAX_HEIGHT),a=TRIANGLE_INTERVAL*t,i=a+r,l=(i+a)/2,s=a+",0 "+i+",0 "+l+","+o,u=this.getRandomOpacityFromInterval(.5,.9);return n.setAttributeNS(null,"points",s),n.setAttributeNS(null,"fill",e),n.setAttributeNS(null,"fill-opacity",u),n}},{key:"makeTopSvg",value:function(){var t=this,e=document.getElementById("TopSvg");this.colors.forEach(function(n,r){var o=t.drawTriangle(r,n);e.appendChild(o)})}},{key:"drawTrianglesFromIndex",value:function(){for(var t=document.getElementById("BottomSvg");this.bottomTriangleIndex*TRIANGLE_INTERVAL<this.bottomTriangleSpan;){var e=this.colors[this.bottomTriangleIndex%4],n=this.drawTriangle(this.bottomTriangleIndex,e);t.appendChild(n),this.bottomTriangleIndex++}}},{key:"makeBottomSvg",value:function(){var t=this;this.drawTrianglesFromIndex(),window.addEventListener("resize",function(e){t.bottomTriangleSpan<window.innerWidth&&(window.requestAnimationFrame(t.drawTrianglesFromIndex.bind(t)),t.bottomTriangleSpan=window.innerWidth)})}}]),t}();exports.default=Triangler;
},{}]},{},[1]);