Skip to content

Commit 8ab6369

Browse files
authored
Map Tap (#57)
* Yoni - added tapping * Yoni - removed useEffect
1 parent a3db03a commit 8ab6369

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

apps/scouting/frontend/src/scouter/components/ScoreMap.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ export const ScoreMap: FC<ScoreMapProps> = ({
108108
const imageRef = useRef<HTMLImageElement | null>(null);
109109
const [mapPoint, setMapPoint] = useState(currentPoint);
110110
const handleMapClick = (event: TouchEvent<HTMLImageElement>) => {
111-
if (!isHolding) {
112-
return;
113-
}
114111
const containerElement = containerRef.current;
115112
const imageElement = imageRef.current;
116113
if (!(containerElement && imageElement)) {
@@ -147,9 +144,14 @@ export const ScoreMap: FC<ScoreMapProps> = ({
147144
<img
148145
ref={imageRef}
149146
src={mapZone === "red" ? redField : blueField}
150-
onTouchMove={handleMapClick}
151-
onTouchStart={() => {
147+
onTouchMove={(event) => {
148+
if (isHolding) {
149+
handleMapClick(event);
150+
}
151+
}}
152+
onTouchStart={(event) => {
152153
setHolding(true);
154+
handleMapClick(event);
153155
}}
154156
onTouchEnd={() => {
155157
setHolding(false);

0 commit comments

Comments
 (0)