LocalCDN-Firefox-Chrome-Brave/resources/granim/2.0.0/granim.min.jsm

2 lines
20 KiB
JavaScript
Raw Normal View History

2022-03-29 06:38:46 +02:00
/*! Granim v2.0.0 - https://sarcadass.github.io/granim.js */
!function t(e,i,s){function o(r,a){if(!i[r]){if(!e[r]){var h="function"==typeof require&&require;if(!a&&h)return h(r,!0);if(n)return n(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var l=i[r]={exports:{}};e[r][0].call(l.exports,function(t){var i=e[r][1][t];return o(i?i:t)},l,l.exports,t,e,i,s)}return i[r].exports}for(var n="function"==typeof require&&require,r=0;r<s.length;r++)o(s[r]);return o}({1:[function(t,e,i){"use strict";function s(t){this.getElement(t.element),this.x1=0,this.y1=0,this.name=t.name||!1,this.elToSetClassOn=t.elToSetClassOn||"body",this.direction=t.direction||"diagonal",this.customDirection=t.customDirection||{},this.validateInput("direction"),this.isPausedWhenNotInView=t.isPausedWhenNotInView||!1,this.states=t.states,this.stateTransitionSpeed=t.stateTransitionSpeed||1e3,this.previousTimeStamp=null,this.progress=0,this.isPaused=!1,this.isCleared=!1,this.isPausedBecauseNotInView=!1,this.context=this.canvas.getContext("2d"),this.channels={},this.channelsIndex=0,this.activeState=t.defaultStateName||"default-state",this.isChangingState=!1,this.currentColors=[],this.currentColorsPos=[],this.activetransitionSpeed=null,this.eventPolyfill(),this.scrollDebounceThreshold=t.scrollDebounceThreshold||300,this.scrollDebounceTimeout=null,this.isImgLoaded=!1,this.isCanvasInWindowView=!1,this.firstScrollInit=!0,this.animating=!1,this.gradientLength=this.states[this.activeState].gradients[0].length,t.image&&t.image.source&&(this.image={source:t.image.source,position:t.image.position||["center","center"],stretchMode:t.image.stretchMode||!1,blendingMode:t.image.blendingMode||!1}),this.events={start:new CustomEvent("granim:start"),end:new CustomEvent("granim:end"),gradientChange:function(t){return new CustomEvent("granim:gradientChange",{detail:{isLooping:t.isLooping,colorsFrom:t.colorsFrom,colorsTo:t.colorsTo,activeState:t.activeState},bubbles:!1,cancelable:!1})}},this.callbacks={onStart:"function"==typeof t.onStart&&t.onStart,onGradientChange:"function"==typeof t.onGradientChange&&t.onGradientChange,onEnd:"function"==typeof t.onEnd&&t.onEnd},this.getDimensions(),this.canvas.setAttribute("width",this.x1),this.canvas.setAttribute("height",this.y1),this.setColors(),this.image&&(this.validateInput("image"),this.prepareImage()),this.pauseWhenNotInViewNameSpace=this.pauseWhenNotInView.bind(this),this.setSizeAttributesNameSpace=this.setSizeAttributes.bind(this),this.onResize(),this.isPausedWhenNotInView?this.onScroll():this.image||(this.refreshColorsAndPos(),this.animation=requestAnimationFrame(this.animateColors.bind(this)),this.animating=!0),this.callbacks.onStart&&this.callbacks.onStart(),this.canvas.dispatchEvent(this.events.start)}s.prototype.animateColors=t("./animateColors.js"),s.prototype.changeBlendingMode=t("./changeBlendingMode.js"),s.prototype.changeDirection=t("./changeDirection.js"),s.prototype.changeState=t("./changeState.js"),s.prototype.clear=t("./clear.js"),s.prototype.convertColorToRgba=t("./convertColorToRgba.js"),s.prototype.destroy=t("./destroy.js"),s.prototype.eventPolyfill=t("./eventPolyfill.js"),s.prototype.getColor=t("./getColor.js"),s.prototype.getColorDiff=t("./getColorDiff.js"),s.prototype.getColorPos=t("./getColorPos.js"),s.prototype.getColorPosDiff=t("./getColorPosDiff.js"),s.prototype.getCurrentColors=t("./getCurrentColors.js"),s.prototype.getCurrentColorsPos=t("./getCurrentColorsPos.js"),s.prototype.getDimensions=t("./getDimensions.js"),s.prototype.getElement=t("./getElement.js"),s.prototype.getLightness=t("./getLightness.js"),s.prototype.makeGradient=t("./makeGradient.js"),s.prototype.onResize=t("./onResize.js"),s.prototype.onScroll=t("./onScroll.js"),s.prototype.pause=t("./pause.js"),s.prototype.pauseWhenNotInView=t("./pauseWhenNotInView.js"),s.prototype.play=t("./play.js"),s.prototype.prepareImage=t("./prepareImage.js"),s.prototype.refreshColorsAndPos=t("./refreshColorsAndPos.js"),s.prototype.setColors=t("./setColors.js"),s.prototype.setDirection=t("./setDirection.js"),s.prototype.setSizeAttributes=t("./setSizeAttributes.js"),s.prototype.triggerError=