fix: bring back shape rotation

This commit is contained in:
Peng Xiao
2022-08-15 21:57:56 +08:00
parent 7fc649dd08
commit d0ddbf19a2
11 changed files with 101 additions and 101 deletions

View File

@@ -1,14 +1,16 @@
import { TLResizeCorner, TLResizeEdge } from '@tldraw/core'
import { TLResizeCorner, TLResizeEdge, TLRotateCorner } from '@tldraw/core'
import { observer } from 'mobx-react-lite'
import { SVGContainer } from '~components'
import type { TLReactShape } from '~lib'
import type { TLSelectionComponentProps } from '~types'
import { CornerHandle, EdgeHandle } from './handles'
import { CornerHandle, EdgeHandle, RotateHandle } from './handles'
import { RotateCornerHandle } from './handles/RotateCornerHandle'
export const SelectionForeground = observer(function SelectionForeground<S extends TLReactShape>({
bounds,
zoom,
showResizeHandles,
showRotateHandles,
shapes,
}: TLSelectionComponentProps<S>) {
const { width, height } = bounds
@@ -66,6 +68,34 @@ export const SelectionForeground = observer(function SelectionForeground<S exten
disabled={!canResize[0]}
isHidden={!showResizeHandles}
/>
<RotateCornerHandle
cx={0}
cy={0}
targetSize={targetSize}
corner={TLRotateCorner.TopLeft}
isHidden={!showRotateHandles}
/>
<RotateCornerHandle
cx={width + targetSize * 2}
cy={0}
targetSize={targetSize}
corner={TLRotateCorner.TopRight}
isHidden={!showRotateHandles}
/>
<RotateCornerHandle
cx={width + targetSize * 2}
cy={height + targetSize * 2}
targetSize={targetSize}
corner={TLRotateCorner.BottomRight}
isHidden={!showRotateHandles}
/>
<RotateCornerHandle
cx={0}
cy={height + targetSize * 2}
targetSize={targetSize}
corner={TLRotateCorner.BottomLeft}
isHidden={!showRotateHandles}
/>
{canResize?.every(r => r) && (
<>
<CornerHandle

View File

@@ -1,5 +1,5 @@
import { TLApp } from '@tldraw/core'
import type { TLReactShape } from './TLReactShape'
import type { TLReactEventMap } from '~types'
import type { TLReactShape } from './TLReactShape'
export class TLReactApp<S extends TLReactShape = TLReactShape> extends TLApp<S, TLReactEventMap> {}