Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
helloyork committed Sep 12, 2024
2 parents b6aaf09 + 0fd745e commit 3ce07c0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/game/player/elements/preload/Img.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use client";

import {Image, Image as GameImage} from "@core/elements/image";
import {GameState} from "@player/gameState";
import React, {useEffect} from "react";

export const Img = React.memo(function ({
state,
image,
onLoad,
}: Readonly<{
state: GameState;
image: GameImage;
onLoad?: () => void;
}>) {
const props: any = {
...image.toHTMLElementProps(),
ref: image.getScope(),
src: image.state.src,
};

useEffect(() => {
const initTransform = image.toTransform();
Object.assign(image.getScope()?.current || {}, initTransform.propToCSS(state, image.state));

image.events.emit(Image.EventTypes["event:image.elementLoaded"]);
}, []);

return (
<img {...props} alt={""} onLoad={onLoad}/>
);
})

0 comments on commit 3ce07c0

Please sign in to comment.