Skip to content

Commit

Permalink
chore: rename functions
Browse files Browse the repository at this point in the history
  • Loading branch information
fand committed Jul 9, 2021
1 parent 7615cf6 commit 4d70329
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
9 changes: 4 additions & 5 deletions src/element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends keyof JSX.IntrinsicElements> =
JSX.IntrinsicElements[T] & VFXProps;

function VFXElementFactory<T extends keyof JSX.IntrinsicElements>(
type: T
Expand All @@ -29,7 +28,7 @@ function VFXElementFactory<T extends keyof JSX.IntrinsicElements>(
shader,
release,
uniforms,
overflow
overflow,
});

return () => {
Expand All @@ -43,7 +42,7 @@ function VFXElementFactory<T extends keyof JSX.IntrinsicElements>(
return;
}

player?.updateElement(ref.current);
player?.updateTextElement(ref.current);
}, [player, props.children]);

return React.createElement(type, { ...props, ref });
Expand Down
10 changes: 5 additions & 5 deletions src/vfx-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -112,7 +112,7 @@ export default class VFXPlayer {
}
};

private async rerender(e: VFXElement): Promise<void> {
private async rerenderTextElement(e: VFXElement): Promise<void> {
try {
e.element.style.setProperty("opacity", "1"); // TODO: Restore original opacity

Expand Down Expand Up @@ -250,10 +250,10 @@ export default class VFXPlayer {
}
}

updateElement(element: HTMLElement): Promise<void> {
updateTextElement(element: HTMLElement): Promise<void> {
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
Expand Down

0 comments on commit 4d70329

Please sign in to comment.