Skip to content

Commit

Permalink
Fix initial player movement
Browse files Browse the repository at this point in the history
  • Loading branch information
maximvl committed Oct 3, 2024
1 parent 9e37109 commit 307fa16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/pages/map/components/DiceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ function isBright(hexColor: string): boolean {
// Calculate luminance
const luminance = 0.2126 * rNorm + 0.7152 * gNorm + 0.0722 * bNorm

console.log('lum', luminance)

// Return true if too bright for dark text
return luminance > 0.45
}
12 changes: 8 additions & 4 deletions src/pages/map/components/PlayerIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export default function PlayerIcon({
return () => clearInterval(interval)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [player.map_position])
}, [player.map_position, isMoving])

// console.log({ player, cell });
if (!anchorCell) {
Expand All @@ -235,9 +235,13 @@ export default function PlayerIcon({

const isStillAnimated = iconRef.current?.src.endsWith('gif')

const finalPositionTop =
isMoving || isStillAnimated ? originTop - 14 : positionTop
const finalPositionLeft = isMoving ? originLeft : positionLeft
let finalPositionTop = positionTop
let finalPositionLeft = positionLeft

if (isMoving || isStillAnimated) {
// adjust height for animation
finalPositionTop = positionTop - 14
}

const handleClick = (event: React.MouseEvent) => {
setPopupAnchor(event.currentTarget as HTMLElement)
Expand Down

0 comments on commit 307fa16

Please sign in to comment.