apply suggestions
continuous-integration/drone/push Build is failing Details

maxime.batista 1 year ago
parent ec46fb78a2
commit 2ffca5a188

1
.gitignore vendored

@ -8,6 +8,7 @@ vendor
composer.lock composer.lock
*.phar *.phar
/dist /dist
.guard
# sqlite database files # sqlite database files
*.sqlite *.sqlite

@ -7,6 +7,7 @@ import {
useLayoutEffect, useLayoutEffect,
useRef, useRef,
useState, useState,
MouseEvent as ReactMouseEvent,
} from "react" } from "react"
import { import {
add, add,
@ -398,14 +399,12 @@ export default function BendableArrow({
} }
}, [update, containerRef]) }, [update, containerRef])
// Inserts a segment where the mouse double clicks on the arrow const addSegment = useCallback(
useEffect(() => { (e: ReactMouseEvent) => {
if (forceStraight) return if (forceStraight) return
const addSegment = (e: MouseEvent) => {
const parentBase = area.current!.getBoundingClientRect() const parentBase = area.current!.getBoundingClientRect()
const clickAbsolutePos: Pos = { x: e.x, y: e.y } const clickAbsolutePos: Pos = { x: e.pageX, y: e.pageY }
const clickPosBaseRatio = ratioWithinBase( const clickPosBaseRatio = ratioWithinBase(
clickAbsolutePos, clickAbsolutePos,
parentBase, parentBase,
@ -473,14 +472,9 @@ export default function BendableArrow({
}, },
), ),
) )
} },
[area, forceStraight, onSegmentsChanges, segments, startPos],
pathRef?.current?.addEventListener("dblclick", addSegment) )
return () => {
pathRef?.current?.removeEventListener("dblclick", addSegment)
}
}, [pathRef, segments, onSegmentsChanges])
return ( return (
<div <div
@ -503,6 +497,7 @@ export default function BendableArrow({
} }
fill="none" fill="none"
tabIndex={0} tabIndex={0}
onDoubleClick={addSegment}
onKeyUp={(e) => { onKeyUp={(e) => {
if (onDeleteRequested && e.key == "Delete") if (onDeleteRequested && e.key == "Delete")
onDeleteRequested() onDeleteRequested()

@ -17,7 +17,7 @@ export interface PlayerProps {
/** /**
* A player that is placed on the court, which can be selected, and moved in the associated bounds * A player that is placed on the court, which can be selected, and moved in the associated bounds
* */ * */
export default function CourtPlayer<A extends ReactNode>({ export default function CourtPlayer({
player, player,
onDrag, onDrag,
onChange, onChange,
@ -50,7 +50,7 @@ export default function CourtPlayer<A extends ReactNode>({
team: player.team, team: player.team,
role: player.role, role: player.role,
hasBall: player.hasBall, hasBall: player.hasBall,
} as Player) })
}}> }}>
<div <div
id={player.id} id={player.id}

Loading…
Cancel
Save