| | |
| | | const [evaluateSubmitVersion, setEvaluateSubmitVersion] = useState(0); |
| | | const [evaluateCloseVersion, setEvaluateCloseVersion] = useState(0); |
| | | const [originOpacity, setOriginOpacity] = useState(1); |
| | | const [originBoxHidden, setOriginBoxHidden] = useState(false); |
| | | const [mapBottomPadding, setMapBottomPadding] = useState(280); |
| | | const [carCalloutStyle, setCarCalloutStyle] = useState<any>({}); |
| | | const [carCalloutVisible, setCarCalloutVisible] = useState(false); |
| | |
| | | |
| | | const updateMapViewportPadding = () => { |
| | | Taro.nextTick(() => { |
| | | Taro.createSelectorQuery() |
| | | .select('.container') |
| | | .boundingClientRect((rect) => { |
| | | const safeInset = resolveSafeBottomInset(); |
| | | const measured = rect?.height ? rect.height + safeInset + 16 : 0; |
| | | const nextPadding = Math.max(280, Math.round(measured)); |
| | | setMapBottomPadding(nextPadding); |
| | | }) |
| | | .exec(); |
| | | const query = Taro.createSelectorQuery(); |
| | | query.select('.container').boundingClientRect(); |
| | | query.select('.origin-box').boundingClientRect(); |
| | | query.select('.map-entry').boundingClientRect(); |
| | | query.exec((res) => { |
| | | const rect = res?.[0]; |
| | | const originRect = res?.[1]; |
| | | const mapEntryRect = res?.[2]; |
| | | const safeInset = resolveSafeBottomInset(); |
| | | const measured = rect?.height ? rect.height + safeInset + 16 : 0; |
| | | const nextPadding = Math.max(280, Math.round(measured)); |
| | | setMapBottomPadding(nextPadding); |
| | | if (originRect && mapEntryRect) { |
| | | const originLeft = originRect.left ?? 0; |
| | | const originTop = originRect.top ?? 0; |
| | | const originRight = originLeft + (originRect.width ?? 0); |
| | | const originBottom = originTop + (originRect.height ?? 0); |
| | | const entryLeft = mapEntryRect.left ?? 0; |
| | | const entryTop = mapEntryRect.top ?? 0; |
| | | const entryRight = entryLeft + (mapEntryRect.width ?? 0); |
| | | const entryBottom = entryTop + (mapEntryRect.height ?? 0); |
| | | const overlap = !(originRight < entryLeft || originLeft > entryRight || originBottom < entryTop || originTop > entryBottom); |
| | | setOriginBoxHidden(overlap); |
| | | } else { |
| | | setOriginBoxHidden(false); |
| | | } |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | |
| | | <View className="container"> |
| | | <View className="container-inner"> |
| | | {/* 复位按钮 */} |
| | | <View className="origin-box" style={{ opacity: originOpacity, transition: 'opacity 0.2s ease-out' }}> |
| | | <View className="origin-box" style={{ opacity: originBoxHidden ? 0 : originOpacity, transition: 'opacity 0.2s ease-out', pointerEvents: originBoxHidden ? 'none' : 'auto' }}> |
| | | <Image onClick={toOrigin} className="origin-icon" src={originIcon} /> |
| | | </View> |
| | | <View catchMove onClick={(e) => e.stopPropagation()}> |