Show paint cursor on incompatible clicks
This commit is contained in:
@@ -686,6 +686,7 @@ function PaintCursorLayer({
|
|||||||
const activePaintTarget = useEditor((s) => s.activePaintTarget)
|
const activePaintTarget = useEditor((s) => s.activePaintTarget)
|
||||||
const paintDisabledFeedbackTick = useEditor((s) => s.paintDisabledFeedbackTick)
|
const paintDisabledFeedbackTick = useEditor((s) => s.paintDisabledFeedbackTick)
|
||||||
const badgeRef = useRef<HTMLDivElement>(null)
|
const badgeRef = useRef<HTMLDivElement>(null)
|
||||||
|
const lastPointerPositionRef = useRef<{ x: number; y: number } | null>(null)
|
||||||
const [showDisabledFeedback, setShowDisabledFeedback] = useState(false)
|
const [showDisabledFeedback, setShowDisabledFeedback] = useState(false)
|
||||||
const active = mode === 'material-paint' && !isVersionPreviewMode
|
const active = mode === 'material-paint' && !isVersionPreviewMode
|
||||||
|
|
||||||
@@ -714,6 +715,7 @@ function PaintCursorLayer({
|
|||||||
const rect = el.getBoundingClientRect()
|
const rect = el.getBoundingClientRect()
|
||||||
nextX = e.clientX - rect.left
|
nextX = e.clientX - rect.left
|
||||||
nextY = e.clientY - rect.top
|
nextY = e.clientY - rect.top
|
||||||
|
lastPointerPositionRef.current = { x: nextX, y: nextY }
|
||||||
|
|
||||||
if (frame === 0) {
|
if (frame === 0) {
|
||||||
frame = window.requestAnimationFrame(flushPosition)
|
frame = window.requestAnimationFrame(flushPosition)
|
||||||
@@ -755,10 +757,16 @@ function PaintCursorLayer({
|
|||||||
if (!paintDisabledFeedbackTick) return
|
if (!paintDisabledFeedbackTick) return
|
||||||
|
|
||||||
const el = containerRef.current
|
const el = containerRef.current
|
||||||
|
const badge = badgeRef.current
|
||||||
|
const lastPointerPosition = lastPointerPositionRef.current
|
||||||
setShowDisabledFeedback(true)
|
setShowDisabledFeedback(true)
|
||||||
if (el) {
|
if (el) {
|
||||||
el.style.cursor = 'not-allowed'
|
el.style.cursor = 'not-allowed'
|
||||||
}
|
}
|
||||||
|
if (badge && lastPointerPosition) {
|
||||||
|
badge.style.display = 'block'
|
||||||
|
badge.style.transform = `translate(${lastPointerPosition.x + PAINT_CURSOR_BADGE_OFFSET_X}px, ${lastPointerPosition.y + PAINT_CURSOR_BADGE_OFFSET_Y}px)`
|
||||||
|
}
|
||||||
const timeoutId = window.setTimeout(() => {
|
const timeoutId = window.setTimeout(() => {
|
||||||
setShowDisabledFeedback(false)
|
setShowDisabledFeedback(false)
|
||||||
if (containerRef.current) {
|
if (containerRef.current) {
|
||||||
|
|||||||
Reference in New Issue
Block a user