fix interactiveSeg offset

This commit is contained in:
Qing 2023-05-03 10:19:40 +08:00
parent f5247c89b2
commit 934289c476
2 changed files with 15 additions and 4 deletions

View File

@ -1060,11 +1060,13 @@ export default function Editor() {
const onCanvasMouseUp = (ev: SyntheticEvent) => {
if (isInteractiveSeg) {
const xy = mouseXY(ev)
const isX = xy.x
const isY = xy.y
const newClicks: number[][] = [...clicks]
if (isRightClick(ev)) {
newClicks.push([xy.x, xy.y, 0, newClicks.length])
newClicks.push([isX, isY, 0, newClicks.length])
} else {
newClicks.push([xy.x, xy.y, 1, newClicks.length])
newClicks.push([isX, isY, 1, newClicks.length])
}
runInteractiveSeg(newClicks)
setClicks(newClicks)
@ -1525,7 +1527,7 @@ export default function Editor() {
style={{
left: `${x}px`,
top: `${y}px`,
// transform: 'translate(-50%, -50%)',
transform: 'translate(-50%, -50%)',
}}
>
<CursorArrowRaysIcon />

View File

@ -12,7 +12,16 @@ interface ItemProps {
const Item = (props: ItemProps) => {
const { x, y, positive } = props
const name = positive ? 'click-item-positive' : 'click-item-negative'
return <div className={`click-item ${name}`} style={{ left: x, top: y }} />
return (
<div
className={`click-item ${name}`}
style={{
left: x,
top: y,
transform: 'translate(-50%, -50%)',
}}
/>
)
}
const InteractiveSeg = () => {