File "vivus.min.js"
Full Path: /home/ycoalition/public_html/blog/wp-content/themes/woodmart/js/libs/vivus.min.js
File size: 10.63 KB
MIME-type: text/plain
Charset: utf-8
"use strict";!function(h,a){function e(t){if(void 0===t)throw new Error('Pathformer [constructor]: "element" parameter is required');if(t.constructor===String&&!(t=a.getElementById(t)))throw new Error('Pathformer [constructor]: "element" parameter is not related to an existing ID');if(!(t.constructor instanceof h.SVGElement||/^svg$/i.test(t.nodeName)))throw new Error('Pathformer [constructor]: "element" parameter must be a string or a SVGelement');this.el=t,this.scan(t)}var r,t,l;function n(t,e,r){this.isReady=!1,this.setElement(t,e),this.setOptions(e),this.setCallback(r),this.isReady&&this.init()}e.prototype.TYPES=["line","ellipse","circle","polygon","polyline","rect"],e.prototype.ATTR_WATCH=["cx","cy","points","r","rx","ry","x","x1","x2","y","y1","y2"],e.prototype.scan=function(t){for(var e,r,n=t.querySelectorAll(this.TYPES.join(",")),i=0;i<n.length;i++)r=(0,this[(e=n[i]).tagName.toLowerCase()+"ToPath"])(this.parseAttr(e.attributes)),r=this.pathMaker(e,r),e.parentNode.replaceChild(r,e)},e.prototype.lineToPath=function(t){var e={},r=t.x1||0,n=t.y1||0,i=t.x2||0,t=t.y2||0;return e.d="M"+r+","+n+"L"+i+","+t,e},e.prototype.rectToPath=function(t){var e={},r=parseFloat(t.x)||0,n=parseFloat(t.y)||0,i=parseFloat(t.width)||0,t=parseFloat(t.height)||0;return e.d="M"+r+" "+n+" ",e.d+="L"+(r+i)+" "+n+" ",e.d+="L"+(r+i)+" "+(n+t)+" ",e.d+="L"+r+" "+(n+t)+" Z",e},e.prototype.polylineToPath=function(t){var e,r={},n=t.points.trim().split(" ");if(-1===t.points.indexOf(",")){for(var i=[],a=0;a<n.length;a+=2)i.push(n[a]+","+n[a+1]);n=i}for(e="M"+n[0],a=1;a<n.length;a++)-1!==n[a].indexOf(",")&&(e+="L"+n[a]);return r.d=e,r},e.prototype.polygonToPath=function(t){t=e.prototype.polylineToPath(t);return t.d+="Z",t},e.prototype.ellipseToPath=function(t){var e={},r=parseFloat(t.rx)||0,n=parseFloat(t.ry)||0,i=parseFloat(t.cx)||0,t=parseFloat(t.cy)||0,a=i-r,s=t,i=parseFloat(i)+parseFloat(r);return e.d="M"+a+","+s+"A"+r+","+n+" 0,1,1 "+i+","+t+"A"+r+","+n+" 0,1,1 "+a+","+t,e},e.prototype.circleToPath=function(t){var e={},r=parseFloat(t.r)||0,n=parseFloat(t.cx)||0,t=parseFloat(t.cy)||0,i=n-r,a=t,n=parseFloat(n)+parseFloat(r);return e.d="M"+i+","+a+"A"+r+","+r+" 0,1,1 "+n+","+t+"A"+r+","+r+" 0,1,1 "+i+","+t,e},e.prototype.pathMaker=function(t,e){for(var r,n=a.createElementNS("http://www.w3.org/2000/svg","path"),i=0;i<t.attributes.length;i++)r=t.attributes[i],-1===this.ATTR_WATCH.indexOf(r.name)&&n.setAttribute(r.name,r.value);for(i in e)n.setAttribute(i,e[i]);return n},e.prototype.parseAttr=function(t){for(var e,r={},n=0;n<t.length;n++){if(e=t[n],-1!==this.ATTR_WATCH.indexOf(e.name)&&-1!==e.value.indexOf("%"))throw new Error("Pathformer [parseAttr]: a SVG shape got values in percentage. This cannot be transformed into 'path' tags. Please use 'viewBox'.");r[e.name]=e.value}return r},n.LINEAR=function(t){return t},n.EASE=function(t){return-Math.cos(t*Math.PI)/2+.5},n.EASE_OUT=function(t){return 1-Math.pow(1-t,3)},n.EASE_IN=function(t){return Math.pow(t,3)},n.EASE_OUT_BOUNCE=function(t){var e=1-Math.cos(t*(.5*Math.PI)),e=Math.pow(e,1.5),t=Math.pow(1-t,2);return 1-t+(1-Math.abs(Math.cos(e*(2.5*Math.PI))))*t},n.prototype.setElement=function(e,t){if(void 0===e)throw new Error('Vivus [constructor]: "element" parameter is required');if(e.constructor===String&&!(e=a.getElementById(e)))throw new Error('Vivus [constructor]: "element" parameter is not related to an existing ID');var r;switch(this.parentEl=e,t&&t.file&&((r=a.createElement("object")).setAttribute("type","image/svg+xml"),r.setAttribute("data",t.file),r.setAttribute("built-by-vivus","true"),e.appendChild(r),e=r),e.constructor){case h.SVGSVGElement:case h.SVGElement:this.el=e,this.isReady=!0;break;case h.HTMLObjectElement:var n=this,i=function(t){if(!n.isReady){if(n.el=e.contentDocument&&e.contentDocument.querySelector("svg"),!n.el&&t)throw new Error("Vivus [constructor]: object loaded does not contain any SVG");return n.el?(e.getAttribute("built-by-vivus")&&(n.parentEl.insertBefore(n.el,e),n.parentEl.removeChild(e),n.el.setAttribute("width","100%"),n.el.setAttribute("height","100%")),n.isReady=!0,n.init(),!0):void 0}};i()||e.addEventListener("load",i);break;default:if(!e)throw new Error('Vivus [constructor]: "element" parameter is not valid (or miss the "file" attribute)')}},n.prototype.setOptions=function(t){var e=["delayed","sync","async","nsync","oneByOne","scenario","scenario-sync"],r=["inViewport","manual","autostart"];if(void 0!==t&&t.constructor!==Object)throw new Error('Vivus [constructor]: "options" parameter must be an object');if((t=t||{}).type&&-1===e.indexOf(t.type))throw new Error("Vivus [constructor]: "+t.type+" is not an existing animation `type`");if(this.type=t.type||e[0],t.start&&-1===r.indexOf(t.start))throw new Error("Vivus [constructor]: "+t.start+" is not an existing `start` option");if(this.start=t.start||r[0],this.isIE=-1!==h.navigator.userAgent.indexOf("MSIE")||-1!==h.navigator.userAgent.indexOf("Trident/")||-1!==h.navigator.userAgent.indexOf("Edge/"),this.duration=l(t.duration,120),this.delay=l(t.delay,null),this.dashGap=l(t.dashGap,1),this.forceRender=t.hasOwnProperty("forceRender")?!!t.forceRender:this.isIE,this.reverseStack=!!t.reverseStack,this.selfDestroy=!!t.selfDestroy,this.onReady=t.onReady,this.map=[],this.frameLength=this.currentFrame=this.delayUnit=this.speed=this.handle=null,this.ignoreInvisible=!!t.hasOwnProperty("ignoreInvisible")&&!!t.ignoreInvisible,this.animTimingFunction=t.animTimingFunction||n.LINEAR,this.pathTimingFunction=t.pathTimingFunction||n.LINEAR,this.delay>=this.duration)throw new Error("Vivus [constructor]: delay must be shorter than duration")},n.prototype.setCallback=function(t){if(t&&t.constructor!==Function)throw new Error('Vivus [constructor]: "callback" parameter must be a function');this.callback=t||function(){}},n.prototype.mapping=function(){for(var t,e,r,n,i,a=n=i=0,s=this.el.querySelectorAll("path"),o=0;o<s.length;o++)t=s[o],this.isInvisible(t)||(r={el:t,length:Math.ceil(t.getTotalLength())},isNaN(r.length)?h.console&&console.warn&&console.warn("Vivus [mapping]: cannot retrieve a path element length",t):(this.map.push(r),t.style.strokeDasharray=r.length+" "+(r.length+2*this.dashGap),t.style.strokeDashoffset=r.length+this.dashGap,r.length+=this.dashGap,n+=r.length,this.renderPath(o)));for(n=0===n?1:n,this.delay=null===this.delay?this.duration/3:this.delay,this.delayUnit=this.delay/(1<s.length?s.length-1:1),this.reverseStack&&this.map.reverse(),o=0;o<this.map.length;o++){switch(r=this.map[o],this.type){case"delayed":r.startAt=this.delayUnit*o,r.duration=this.duration-this.delay;break;case"oneByOne":r.startAt=i/n*this.duration,r.duration=r.length/n*this.duration;break;case"sync":case"async":case"nsync":r.startAt=0,r.duration=this.duration;break;case"scenario-sync":t=r.el,e=this.parseAttr(t),r.startAt=a+(l(e["data-delay"],this.delayUnit)||0),r.duration=l(e["data-duration"],this.duration),a=void 0!==e["data-async"]?r.startAt:r.startAt+r.duration,this.frameLength=Math.max(this.frameLength,r.startAt+r.duration);break;case"scenario":t=r.el,e=this.parseAttr(t),r.startAt=l(e["data-start"],this.delayUnit)||0,r.duration=l(e["data-duration"],this.duration),this.frameLength=Math.max(this.frameLength,r.startAt+r.duration)}i+=r.length,this.frameLength=this.frameLength||this.duration}},n.prototype.drawer=function(){var t=this;if(this.currentFrame+=this.speed,this.currentFrame<=0)this.stop(),this.reset();else{if(!(this.currentFrame>=this.frameLength))return this.trace(),void(this.handle=r(function(){t.drawer()}));this.stop(),this.currentFrame=this.frameLength,this.trace(),this.selfDestroy&&this.destroy()}this.callback(this),this.instanceCallback&&(this.instanceCallback(this),this.instanceCallback=null)},n.prototype.trace=function(){for(var t,e,r=this.animTimingFunction(this.currentFrame/this.frameLength)*this.frameLength,n=0;n<this.map.length;n++)t=(r-(e=this.map[n]).startAt)/e.duration,t=this.pathTimingFunction(Math.max(0,Math.min(1,t))),e.progress!==t&&(e.progress=t,e.el.style.strokeDashoffset=Math.floor(e.length*(1-t)),this.renderPath(n))},n.prototype.renderPath=function(t){var e;this.forceRender&&this.map&&this.map[t]&&(e=(t=this.map[t]).el.cloneNode(!0),t.el.parentNode.replaceChild(e,t.el),t.el=e)},n.prototype.init=function(){this.frameLength=0,this.currentFrame=0,this.map=[],new e(this.el),this.mapping(),this.starter(),this.onReady&&this.onReady(this)},n.prototype.starter=function(){switch(this.start){case"manual":return;case"autostart":this.play();break;case"inViewport":var t=this,e=function(){t.isInViewport(t.parentEl,1)&&(t.play(),h.removeEventListener("scroll",e))};h.addEventListener("scroll",e),e()}},n.prototype.getStatus=function(){return 0===this.currentFrame?"start":this.currentFrame===this.frameLength?"end":"progress"},n.prototype.reset=function(){return this.setFrameProgress(0)},n.prototype.finish=function(){return this.setFrameProgress(1)},n.prototype.setFrameProgress=function(t){return t=Math.min(1,Math.max(0,t)),this.currentFrame=Math.round(this.frameLength*t),this.trace(),this},n.prototype.play=function(t,e){if(this.instanceCallback=null,t&&"function"==typeof t)this.instanceCallback=t,t=null;else if(t&&"number"!=typeof t)throw new Error("Vivus [play]: invalid speed");return e&&"function"==typeof e&&!this.instanceCallback&&(this.instanceCallback=e),this.speed=t||1,this.handle||this.drawer(),this},n.prototype.stop=function(){return this.handle&&(t(this.handle),this.handle=null),this},n.prototype.destroy=function(){var t,e;for(this.stop(),t=0;t<this.map.length;t++)(e=this.map[t]).el.style.strokeDashoffset=null,e.el.style.strokeDasharray=null,this.renderPath(t)},n.prototype.isInvisible=function(t){var e=t.getAttribute("data-ignore");return null!==e?"false"!==e:!!this.ignoreInvisible&&(!(e=t.getBoundingClientRect()).width&&!e.height)},n.prototype.parseAttr=function(t){var e,r={};if(t&&t.attributes)for(var n=0;n<t.attributes.length;n++)r[(e=t.attributes[n]).name]=e.value;return r},n.prototype.isInViewport=function(t,e){var r=this.scrollY(),n=r+this.getViewportH(),t=t.getBoundingClientRect(),i=t.height,t=r+t.top;return t+i*(e=e||0)<=n&&r<=t+i},n.prototype.docElem=h.document.documentElement,n.prototype.getViewportH=function(){var t=this.docElem.clientHeight,e=h.innerHeight;return t<e?e:t},n.prototype.scrollY=function(){return h.pageYOffset||this.docElem.scrollTop},r=h.requestAnimationFrame||h.webkitRequestAnimationFrame||h.mozRequestAnimationFrame||h.oRequestAnimationFrame||h.msRequestAnimationFrame||function(t){return h.setTimeout(t,1e3/60)},t=h.cancelAnimationFrame||h.webkitCancelAnimationFrame||h.mozCancelAnimationFrame||h.oCancelAnimationFrame||h.msCancelAnimationFrame||function(t){return h.clearTimeout(t)},l=function(t,e){t=parseInt(t,10);return 0<=t?t:e},"function"==typeof define&&define.amd?define([],function(){return n}):"object"==typeof exports?module.exports=n:h.Vivus=n}(window,document);