Skip to content

Commit 94171fa

Browse files
authored
fix: 修复重新设置path后鼠标事件失效 (#372)
1 parent cdcfc2c commit 94171fa

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/polygon/src/usePolygon.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ export const usePolygon = (props = {} as UsePolygon) => {
3333

3434
useEffect(() => {
3535
if (polygon) {
36-
polygon.setOptions(other);
36+
const { path, ...rest } = other;
37+
if (path) {
38+
polygon.setPath(path);
39+
}
40+
polygon.setOptions(rest);
3741
}
3842
}, [polygon, other]);
3943

packages/polyline/src/usePolyline.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ export function usePolyline(props = {} as UsePolyline) {
3333

3434
useEffect(() => {
3535
if (polyline) {
36-
polyline.setOptions(other);
36+
const { path, ...rest } = other;
37+
if (path) {
38+
polyline.setPath(path);
39+
}
40+
polyline.setOptions(rest);
3741
}
3842
}, [polyline, other]);
3943

0 commit comments

Comments
 (0)