|
@@ -17,6 +17,7 @@ const FloatingWindow: React.FC<Props> = ({ isVer, onClick }) => {
|
|
|
/**********************************/
|
|
|
const { state: { initData: { h5SignLogo } } } = useContext(DispatchContext)!;
|
|
|
const [isDragging, setIsDragging] = useState(false);
|
|
|
+ const [nowTimer, setNowTimer] = useState<number>(0)
|
|
|
const [position, setPosition] = useState({ x: 0, y: 200 });
|
|
|
const ref = useRef(null);
|
|
|
const size = useSize(ref);
|
|
@@ -36,6 +37,7 @@ const FloatingWindow: React.FC<Props> = ({ isVer, onClick }) => {
|
|
|
|
|
|
const handleMouseDown = (event: React.MouseEvent<HTMLDivElement>) => {
|
|
|
event.stopPropagation()
|
|
|
+ setNowTimer(new Date().getTime())
|
|
|
setIsDragging(true);
|
|
|
setPosition({ x: event.clientX, y: event.clientY });
|
|
|
};
|
|
@@ -46,8 +48,14 @@ const FloatingWindow: React.FC<Props> = ({ isVer, onClick }) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- const handleMouseUp = () => {
|
|
|
+ const handleMouseUp = (e: any) => {
|
|
|
setIsDragging(false);
|
|
|
+ if (new Date().getTime() - nowTimer < 200) {
|
|
|
+ setNowTimer(0)
|
|
|
+ onClick?.(e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ setNowTimer(0)
|
|
|
let drawW = size?.width || 0;
|
|
|
let bodyW = document.body.clientWidth;
|
|
|
let bodyH = document.body.clientHeight;
|
|
@@ -94,6 +102,10 @@ const FloatingWindow: React.FC<Props> = ({ isVer, onClick }) => {
|
|
|
setPosition({ x: touch.clientX, y: touch.clientY });
|
|
|
};
|
|
|
|
|
|
+ // const clickHandle = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
|
|
+ // // if (!isDragging) onClick?.(e)
|
|
|
+ // }
|
|
|
+
|
|
|
return (
|
|
|
<div
|
|
|
ref={ref}
|
|
@@ -111,7 +123,7 @@ const FloatingWindow: React.FC<Props> = ({ isVer, onClick }) => {
|
|
|
onTouchStart={onTouchStart}
|
|
|
onTouchMove={onTouchMove}
|
|
|
onTouchEnd={handleMouseUp}
|
|
|
- onClick={(e) => { e.stopPropagation(); if (!isDragging) onClick?.(e) }}
|
|
|
+ // onClick={(e) => { e.stopPropagation(); clickHandle(e) }}
|
|
|
/>
|
|
|
);
|
|
|
};
|