|
@@ -151,6 +151,12 @@ function A1svgBox({ opc = 1, id = '', closeFu }: Props) {
|
|
|
store.dispatch({ type: 'layout/svgAcGlobal', payload: obj.code })
|
|
|
history.replace(`/scene/${obj.code}?k=${ttsxsysid}&n=${myPhone}&t=${taskId}`)
|
|
|
if (closeFu) closeFu()
|
|
|
+
|
|
|
+ // setTimeout(() => {
|
|
|
+ // if (flagRef.current) {
|
|
|
+
|
|
|
+ // }
|
|
|
+ // }, 20)
|
|
|
}
|
|
|
|
|
|
dom.onmouseleave = () => {
|
|
@@ -168,12 +174,59 @@ function A1svgBox({ opc = 1, id = '', closeFu }: Props) {
|
|
|
// tit提示语
|
|
|
const [tit, setTit] = useState(true)
|
|
|
|
|
|
+ // -------------------------------
|
|
|
+ // 记录鼠标按下的初始位置
|
|
|
+ const [startPos, setStartPos] = useState<{ x: number; y: number } | null>(null)
|
|
|
+
|
|
|
+ // 使用ref来存储位移阈值,避免在回调中读取到旧的state值
|
|
|
+ const dragThreshold = useRef(20)
|
|
|
+
|
|
|
+ const flagRef = useRef(true)
|
|
|
+
|
|
|
+ // 处理鼠标按下事件
|
|
|
+ const handleMouseDown = useCallback((e: React.MouseEvent<HTMLDivElement>) => {
|
|
|
+ flagRef.current = true
|
|
|
+ // 记录初始位置
|
|
|
+ setStartPos({ x: e.clientX, y: e.clientY })
|
|
|
+ // 如果需要,可以在这里阻止默认行为或冒泡
|
|
|
+ // e.preventDefault();
|
|
|
+ // e.stopPropagation();
|
|
|
+ }, [])
|
|
|
+
|
|
|
+ // 处理鼠标松开事件
|
|
|
+ const handleMouseUp = useCallback(
|
|
|
+ (e: React.MouseEvent<HTMLDivElement>) => {
|
|
|
+ if (startPos) {
|
|
|
+ const deltaX = Math.abs(e.clientX - startPos.x)
|
|
|
+ const deltaY = Math.abs(e.clientY - startPos.y)
|
|
|
+
|
|
|
+ // 判断位移是否小于阈值(例如20像素)
|
|
|
+ if (deltaX < dragThreshold.current && deltaY < dragThreshold.current) {
|
|
|
+ // 认为是点击操作,触发点击事件
|
|
|
+ flagRef.current = true
|
|
|
+ } else flagRef.current = false
|
|
|
+ // 否则,这里是拖动操作,不触发点击事件
|
|
|
+
|
|
|
+ // 重置初始位置和拖动状态
|
|
|
+ setStartPos(null)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ [startPos]
|
|
|
+ )
|
|
|
+
|
|
|
return (
|
|
|
<div
|
|
|
+ onMouseDown={handleMouseDown}
|
|
|
+ onMouseUp={handleMouseUp}
|
|
|
+ // pc拖动点击冲突问题
|
|
|
onTouchStart={() => setTit(false)}
|
|
|
onClick={() => setTit(false)}
|
|
|
className={classNames(styles.A1svgBox, isMobileFu() ? styles.A1svgBoxM : '')}
|
|
|
- style={{ opacity: opc, pointerEvents: opc ? 'auto' : 'none' }}
|
|
|
+ style={{
|
|
|
+ opacity: opc,
|
|
|
+ pointerEvents: opc ? 'auto' : 'none',
|
|
|
+ cursor: 'grab'
|
|
|
+ }}
|
|
|
id={id}
|
|
|
>
|
|
|
{/* 右上角关闭按钮 */}
|