2 lines
9.2 KiB
JavaScript
2 lines
9.2 KiB
JavaScript
|
|
"use strict";(self.webpackChunkmontana_messenger=self.webpackChunkmontana_messenger||[]).push([[6708],{66708(e,t,s){s.d(t,{default:()=>F});var i=s(19822),a=s(96454),r=s(67054),n=s(9705),o=s(14235),h=s(41074),d=s(66644);const c=Symbol("WAITING"),m=a.Ni||a.pz?.75:1,l=a.Ni?.5:.75,p=24,g=a.Yw?2:4,u=(0,h.Ay)().map(({connector:e})=>e),f=new Map,y=new WeakMap;let w=-1;class x{views=new Map;msPerFrame=1e3/60;reduceFactor=1;frames=[];isAnimating=!1;isWaiting=!0;isEnded=!1;isDestroyed=!1;isRendererInited=!1;approxFrameIndex=0;prevFrameIndex=-1;stopFrameIndex=0;speed=1;direction=1;requestedSeekToEnd=!1;static init(...e){const[,t,s,i,a=(0,o.A)(),,r,,,n]=e;let h=f.get(s);return h?h.addView(a,t,r,n,i?.coords):(h=new x(...e),f.set(s,h)),h}constructor(e,t,s,i,a=(0,o.A)(),r,n,h,d,c){this.tgsUrl=e,this.renderId=s,this.params=i,this.customColor=r,this.onEnded=h,this.onLoop=d,this.addView(a,t,n,c,i.coords),this.initConfig(),this.initRenderer()}removeView(e){const{canvas:t,ctx:s,isSharedCanvas:i,coords:a}=this.views.get(e);i?s.clearRect(a.x,a.y,this.imgSize,this.imgSize):t.remove(),this.views.delete(e),this.views.size||this.destroy()}isPlaying(){return this.isAnimating||this.isWaiting}play(e=!1,t){t&&(this.views.get(t).isPaused=!1),this.isEnded&&e&&(this.approxFrameIndex=Math.floor(0)),this.stopFrameIndex=void 0,this.direction=1,this.doPlay()}pause(e){this.lastRenderAt=void 0,(!e||(this.views.get(e).isPaused=!0,Array.from(this.views.values()).every(({isPaused:e})=>e)))&&(this.isWaiting?this.stopFrameIndex=this.approxFrameIndex:this.isAnimating=!1,this.params.isLowPriority||(this.frames=this.frames.map((e,t)=>t===this.prevFrameIndex?e:void(e&&e!==c&&e.close()))))}playSegment([e,t],s=!1,i){i&&(this.views.get(i).isPaused=!1);const a=Math.round(this.approxFrameIndex);this.stopFrameIndex=Math.floor(t/this.reduceFactor),(a!==t||s)&&(this.approxFrameIndex=Math.floor(e/this.reduceFactor)),this.direction=e<t?1:-1,this.doPlay()}seekToEnd(){this.requestedSeekToEnd=!0,this.doPlay()}setSpeed(e){this.speed=e}setNoLoop(e){this.params.noLoop=e}async setSharedCanvasCoords(e,t){const s=this.views.get(e),{canvas:i,ctx:a}=s,r=!i.dataset.isJustCleaned||"false"===i.dataset.isJustCleaned;r||await y.get(i);let[n,o]=[i.width,i.height];if(r){const e=this.calcSizeFactor();[n,o]=v(i,e),a.clearRect(0,0,n,o),i.dataset.isJustCleaned="true",(0,d.YS)(()=>{i.dataset.isJustCleaned="false"})}s.coords={x:Math.round((t?.x||0)*n),y:Math.round((t?.y||0)*o)};const h=this.getFrame(this.prevFrameIndex)||this.getFrame(Math.round(this.approxFrameIndex));h&&h!==c&&a.drawImage(h,s.coords.x,s.coords.y)}addView(e,t,s,i,a){const r=this.calcSizeFactor();let n;if(t instanceof HTMLDivElement){if(!(t.parentNode instanceof HTMLElement))throw new Error("[RLottie] Container is not mounted");const{size:a}=this.params;n=Math.round(a*r),this.imgSize||(this.imgSize=n,this.imageData=new ImageData(n,n)),(0,d.RK)(()=>{const r=document.createElement("canvas"),o=r.getContext("2d");r.classList.add("rlottie-canvas"),r.style.width=`${a}px`,r.style.height=`${a}px`,r.width=n,r.height=n,t.appendChild(r),this.views.set(e,{canvas:r,ctx:o,onLoad:s,onFrame:i})})}else{if(!t.isConnected)throw new Error("[RLottie] Shared canvas is not mounted");const i=t,o=i.getContext("2d");n=Math.round(this.params.size*r),this.imgSize||(this.imgSize=n,this.imageData=new ImageData(n,n));const[h,d]=v(i,r);this.views.set(e,{canvas:i,ctx:o,isSharedCanvas:!0,coords:{x:Math.round(a.x*h),y:Math.round(a.y*d)},onLoad:s})}this.isRendererInited&&this.doPlay()}calcSizeFactor(){const{size:e,isLowPriority:t,quality:s=(t&&(!e||e>p)?l:m)}=this.params;return Math.max(window.devicePixelRatio*s,1)}destroy(){this.isDestroyed=!0,this.pause(),this.clearCache(),this.destroyRenderer(),f.delete(this.renderId)}clearCache(){this.frames.forEach(e=>{e&&e!==c&&e.close()}),this.imageData=void 0,this.frames=[]}initConfig(){const{isLowPriority:e}=this.params;this.cacheModulo=e?0:g}setColor(e){this.customColor=e}initRenderer(){this.workerIndex=(0,r.A)(h.bP,++w),u[this.workerIndex].request({name:"rlottie:init",args:[this.renderId,this.tgsUrl,this.imgSize,this.params.
|
||
|
|
//# sourceMappingURL=6708.bd8c12bd2ecfbe4af552.js.map
|