Skip to content

Commit

Permalink
feat: random pose (decentraland#577)
Browse files Browse the repository at this point in the history
  • Loading branch information
cazala authored Mar 14, 2022
1 parent be2a509 commit 9063e26
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion webapp/src/components/AssetImage/AssetImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ const AssetImage = (props: Props) => {

const [isTracked, setIsTracked] = useState(false)

// pick a random emote
const emote = useMemo(() => {
const poses = [
AvatarEmote.FASHION,
AvatarEmote.FASHION_2,
AvatarEmote.FASHION_3
]
return isTryingOn ? poses[(Math.random() * poses.length) | 0] : undefined
}, [isTryingOn])

// This effect is here just to track on which mode the preview is initialized, that's why it has an empty dependency array, so this is triggered once on mount
useEffect(() => {
const isPreview = asset.category === NFTCategory.WEARABLE && isDraggable
if (!isTracked && isPreview) {
Expand Down Expand Up @@ -192,7 +203,7 @@ const AssetImage = (props: Props) => {
}
skin={skin}
hair={hair}
emote={AvatarEmote.FASHION}
emote={emote}
onLoad={handleLoad}
onError={handleError}
dev={isDev}
Expand Down

0 comments on commit 9063e26

Please sign in to comment.