From 4d7032922d688f3727ae6a313bee9b5904081a06 Mon Sep 17 00:00:00 2001 From: Takayosi Amagi Date: Fri, 9 Jul 2021 11:04:07 +0900 Subject: [PATCH] chore: rename functions --- src/element.tsx | 9 ++++----- src/vfx-player.ts | 10 +++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/element.tsx b/src/element.tsx index 7e990cf..c031e0a 100644 --- a/src/element.tsx +++ b/src/element.tsx @@ -3,9 +3,8 @@ import { useEffect, useRef, useContext } from "react"; import { VFXContext } from "./context"; import { VFXProps } from "./types"; -type VFXElementProps< - T extends keyof JSX.IntrinsicElements -> = JSX.IntrinsicElements[T] & VFXProps; +type VFXElementProps = + JSX.IntrinsicElements[T] & VFXProps; function VFXElementFactory( type: T @@ -29,7 +28,7 @@ function VFXElementFactory( shader, release, uniforms, - overflow + overflow, }); return () => { @@ -43,7 +42,7 @@ function VFXElementFactory( return; } - player?.updateElement(ref.current); + player?.updateTextElement(ref.current); }, [player, props.children]); return React.createElement(type, { ...props, ref }); diff --git a/src/vfx-player.ts b/src/vfx-player.ts index 9836713..732dfe8 100644 --- a/src/vfx-player.ts +++ b/src/vfx-player.ts @@ -79,7 +79,7 @@ export default class VFXPlayer { if (e.type === "text" && e.isInViewport) { const rect = e.element.getBoundingClientRect(); if (rect.width !== e.width || rect.height !== e.height) { - await this.rerender(e); + await this.rerenderTextElement(e); e.width = rect.width; e.height = rect.height; } @@ -89,7 +89,7 @@ export default class VFXPlayer { if (e.type === "text" && !e.isInViewport) { const rect = e.element.getBoundingClientRect(); if (rect.width !== e.width || rect.height !== e.height) { - await this.rerender(e); + await this.rerenderTextElement(e); e.width = rect.width; e.height = rect.height; } @@ -112,7 +112,7 @@ export default class VFXPlayer { } }; - private async rerender(e: VFXElement): Promise { + private async rerenderTextElement(e: VFXElement): Promise { try { e.element.style.setProperty("opacity", "1"); // TODO: Restore original opacity @@ -250,10 +250,10 @@ export default class VFXPlayer { } } - updateElement(element: HTMLElement): Promise { + updateTextElement(element: HTMLElement): Promise { const i = this.elements.findIndex((e) => e.element === element); if (i !== -1) { - return this.rerender(this.elements[i]); + return this.rerenderTextElement(this.elements[i]); } // Do nothing if the element is not found