Fixed some formatting issues
							parent
							
								
									daa03098f3
								
							
						
					
					
						commit
						c7d535d2d3
					
				| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
import React, {FunctionComponent, useEffect, useRef} from 'react';
 | 
			
		||||
import React, { FunctionComponent, useEffect, useRef } from 'react';
 | 
			
		||||
import dis from '../../../../dispatcher/dispatcher';
 | 
			
		||||
import ICanvasEffect from './ICanvasEffect.js';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ type EffectsOverlayProps = {
 | 
			
		|||
    roomWidth: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const EffectsOverlay: FunctionComponent<EffectsOverlayProps> = ({roomWidth}) => {
 | 
			
		||||
const EffectsOverlay: FunctionComponent<EffectsOverlayProps> = ({ roomWidth }) => {
 | 
			
		||||
    const canvasRef = useRef<HTMLCanvasElement>(null);
 | 
			
		||||
    const effectsRef = useRef<Map<String, ICanvasEffect>>(new Map<String, ICanvasEffect>());
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -15,9 +15,9 @@ const EffectsOverlay: FunctionComponent<EffectsOverlayProps> = ({roomWidth}) =>
 | 
			
		|||
    };
 | 
			
		||||
 | 
			
		||||
    const lazyLoadEffectModule = async (name: string): Promise<ICanvasEffect> => {
 | 
			
		||||
        if(!name) return null;
 | 
			
		||||
        if (!name) return null;
 | 
			
		||||
        let effect = effectsRef.current[name] ?? null;
 | 
			
		||||
        if(effect === null) {
 | 
			
		||||
        if (effect === null) {
 | 
			
		||||
            try {
 | 
			
		||||
                var { default: Effect } = await import(`./${name}`);
 | 
			
		||||
                effect = new Effect();
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +31,7 @@ const EffectsOverlay: FunctionComponent<EffectsOverlayProps> = ({roomWidth}) =>
 | 
			
		|||
 | 
			
		||||
    const onAction = (payload: { action: string }) => {
 | 
			
		||||
        const actionPrefix = 'effects.';
 | 
			
		||||
        if(payload.action.indexOf(actionPrefix) === 0) {
 | 
			
		||||
        if (payload.action.indexOf(actionPrefix) === 0) {
 | 
			
		||||
            const effect = payload.action.substr(actionPrefix.length);
 | 
			
		||||
            lazyLoadEffectModule(effect).then((module) => module?.start(canvasRef.current));
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -48,7 +48,7 @@ const EffectsOverlay: FunctionComponent<EffectsOverlayProps> = ({roomWidth}) =>
 | 
			
		|||
        return () => {
 | 
			
		||||
            dis.unregister(dispatcherRef);
 | 
			
		||||
            window.removeEventListener('resize', resize);
 | 
			
		||||
            for(const effect in effectsRef.current) {
 | 
			
		||||
            for (const effect in effectsRef.current) {
 | 
			
		||||
                effectsRef.current[effect]?.stop();
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -65,16 +65,16 @@ export default class Confetti implements ICanvasEffect {
 | 
			
		|||
    public isRunning: boolean;
 | 
			
		||||
 | 
			
		||||
    public start = async (canvas: HTMLCanvasElement, timeout = 3000) => {
 | 
			
		||||
        if(!canvas) {
 | 
			
		||||
        if (!canvas) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        window.requestAnimationFrame = (function () {
 | 
			
		||||
        window.requestAnimationFrame = (function() {
 | 
			
		||||
            return window.requestAnimationFrame ||
 | 
			
		||||
                window.webkitRequestAnimationFrame ||
 | 
			
		||||
                window.mozRequestAnimationFrame ||
 | 
			
		||||
                window.oRequestAnimationFrame ||
 | 
			
		||||
                window.msRequestAnimationFrame ||
 | 
			
		||||
                function (callback) {
 | 
			
		||||
                function(callback) {
 | 
			
		||||
                    return window.setTimeout(callback, this.options.frameInterval);
 | 
			
		||||
                };
 | 
			
		||||
        })();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
import {_t, _td} from "../../../../languageHandler";
 | 
			
		||||
import { _t, _td } from "../../../../languageHandler";
 | 
			
		||||
 | 
			
		||||
type Effect = {
 | 
			
		||||
    emojis: Array<string>;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue