Browse Source

feat: 响应聚焦文本点击事件

pull/3/head
jiannibang 3 years ago
parent
commit
39e1dda3ff
  1. 19
      src/pages/Index/Index.js

19
src/pages/Index/Index.js

@ -43,6 +43,7 @@ const Index = () => {
const [start, _setStart] = useState(null); const [start, _setStart] = useState(null);
const [end, _setEnd] = useState(null); const [end, _setEnd] = useState(null);
const [doFocus, _setDoFocus] = useState(0); const [doFocus, _setDoFocus] = useState(0);
const [focusTextClicked, setFocusTextClicked] = useState(false);
useEffect(() => { useEffect(() => {
if (!map) return; if (!map) return;
@ -308,6 +309,7 @@ const Index = () => {
}, },
onAzimuthAngleChange: (angle) => onAzimuthAngleChange: (angle) =>
setAzimuthAngle(Math.floor((angle / Math.PI) * 180)), setAzimuthAngle(Math.floor((angle / Math.PI) * 180)),
onFocusTextClick: () => setFocusTextClicked(true),
}); });
}; };
@ -336,6 +338,19 @@ const Index = () => {
} }
}, [mallInfo]); }, [mallInfo]);
useEffect(() => {
if (focusTextClicked) {
if (shop) {
setEnd(shop);
map.startNavigate({
start,
end: shop,
});
}
setFocusTextClicked(false);
}
}, [focusTextClicked]);
return ( return (
<MallCode.Provider value={mallCode}> <MallCode.Provider value={mallCode}>
<div className="index"> <div className="index">
@ -367,9 +382,7 @@ const Index = () => {
)} )}
<div <div
className={["compass-wrapper", inAnimation ? "inNav" : ""].join(
" "
)}
className={["compass-wrapper", showNav ? "inNav" : ""].join(" ")}
> >
<img <img
className="compass" className="compass"

Loading…
Cancel
Save