Restores selected indicator, removes hook for isSelected on shape
This commit is contained in:
parent
75beaf2516
commit
9877c2ff97
3 changed files with 14 additions and 15 deletions
|
@ -56,14 +56,13 @@ export default function Canvas() {
|
||||||
onPointerMove={handlePointerMove}
|
onPointerMove={handlePointerMove}
|
||||||
onPointerUp={handlePointerUp}
|
onPointerUp={handlePointerUp}
|
||||||
onTouchStart={handleTouchStart}
|
onTouchStart={handleTouchStart}
|
||||||
// onTouchMove={handleTouchMove}
|
|
||||||
>
|
>
|
||||||
<Defs />
|
<Defs />
|
||||||
{isReady && (
|
{isReady && (
|
||||||
<g ref={rGroup}>
|
<g ref={rGroup}>
|
||||||
<BoundsBg />
|
<BoundsBg />
|
||||||
<Page />
|
<Page />
|
||||||
{/* <Selected /> */}
|
<Selected />
|
||||||
<Bounds />
|
<Bounds />
|
||||||
<Handles />
|
<Handles />
|
||||||
<Brush />
|
<Brush />
|
||||||
|
|
|
@ -8,8 +8,6 @@ import useShapeEvents from 'hooks/useShapeEvents'
|
||||||
import { getShapeStyle } from 'lib/shape-styles'
|
import { getShapeStyle } from 'lib/shape-styles'
|
||||||
|
|
||||||
function Shape({ id, isSelecting }: { id: string; isSelecting: boolean }) {
|
function Shape({ id, isSelecting }: { id: string; isSelecting: boolean }) {
|
||||||
const isSelected = useSelector((s) => s.values.selectedIds.has(id))
|
|
||||||
|
|
||||||
const shape = useSelector(({ data }) => getPage(data).shapes[id])
|
const shape = useSelector(({ data }) => getPage(data).shapes[id])
|
||||||
|
|
||||||
const rGroup = useRef<SVGGElement>(null)
|
const rGroup = useRef<SVGGElement>(null)
|
||||||
|
@ -32,7 +30,7 @@ function Shape({ id, isSelecting }: { id: string; isSelecting: boolean }) {
|
||||||
const style = getShapeStyle(shape.style)
|
const style = getShapeStyle(shape.style)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledGroup ref={rGroup} isSelected={isSelected} transform={transform}>
|
<StyledGroup ref={rGroup} transform={transform}>
|
||||||
{isSelecting && (
|
{isSelecting && (
|
||||||
<HoverIndicator
|
<HoverIndicator
|
||||||
as="use"
|
as="use"
|
||||||
|
@ -86,6 +84,9 @@ const StyledGroup = styled('g', {
|
||||||
[`& ${HoverIndicator}`]: {
|
[`& ${HoverIndicator}`]: {
|
||||||
opacity: '0',
|
opacity: '0',
|
||||||
},
|
},
|
||||||
|
[`&:hover ${HoverIndicator}`]: {
|
||||||
|
opacity: '0.16',
|
||||||
|
},
|
||||||
variants: {
|
variants: {
|
||||||
isSelected: {
|
isSelected: {
|
||||||
true: {
|
true: {
|
||||||
|
@ -103,9 +104,6 @@ const StyledGroup = styled('g', {
|
||||||
[`& ${HoverIndicator}`]: {
|
[`& ${HoverIndicator}`]: {
|
||||||
opacity: '0',
|
opacity: '0',
|
||||||
},
|
},
|
||||||
[`&:hover ${HoverIndicator}`]: {
|
|
||||||
opacity: '0.16',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { current } from "immer"
|
import { current } from 'immer'
|
||||||
import { Bounds, Data } from "types"
|
import { Bounds, Data } from 'types'
|
||||||
import BaseSession from "./base-session"
|
import BaseSession from './base-session'
|
||||||
import { getShapeUtils } from "lib/shape-utils"
|
import { getShapeUtils } from 'lib/shape-utils'
|
||||||
import { getBoundsFromPoints, getShapes } from "utils/utils"
|
import { getBoundsFromPoints, getShapes } from 'utils/utils'
|
||||||
import * as vec from "utils/vec"
|
import * as vec from 'utils/vec'
|
||||||
|
|
||||||
export default class BrushSession extends BaseSession {
|
export default class BrushSession extends BaseSession {
|
||||||
origin: number[]
|
origin: number[]
|
||||||
|
@ -25,7 +25,9 @@ export default class BrushSession extends BaseSession {
|
||||||
for (let id in snapshot.shapeHitTests) {
|
for (let id in snapshot.shapeHitTests) {
|
||||||
const test = snapshot.shapeHitTests[id]
|
const test = snapshot.shapeHitTests[id]
|
||||||
if (test(brushBounds)) {
|
if (test(brushBounds)) {
|
||||||
|
if (!data.selectedIds.has(id)) {
|
||||||
data.selectedIds.add(id)
|
data.selectedIds.add(id)
|
||||||
|
}
|
||||||
} else if (data.selectedIds.has(id)) {
|
} else if (data.selectedIds.has(id)) {
|
||||||
data.selectedIds.delete(id)
|
data.selectedIds.delete(id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue