Skip to content

Commit 3e394d0

Browse files
authored
Merge pull request #650 from Suntgr/feat/zy-setzoom
perf: Optimize setzoom with debounce in PointCloudTopView
2 parents 83bbcfa + 6a95781 commit 3e394d0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/lb-components/src/components/pointCloudView/PointCloudTopView.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import _ from 'lodash';
4747
import PointCloudSizeSlider from './components/PointCloudSizeSlider';
4848
import { useHistory } from './hooks/useHistory';
4949
import TitleButton from './components/TitleButton';
50+
import { useDebounceFn } from 'ahooks';
5051

5152
const { EPolygonPattern, EToolName } = cTool;
5253
const { ESortDirection } = cAnnotation;
@@ -208,6 +209,9 @@ const PointCloudTopView: React.FC<IProps> = ({
208209
const size = useSize(ref);
209210
const config = jsonParser(stepInfo.config);
210211
const { setZoom, syncTopviewToolZoom } = useZoom();
212+
213+
const { run: debouncedSetZoom } = useDebounceFn(setZoom, { wait: 500 });
214+
211215
const { hideAttributes, setIsLargeStatus, selectedID, pointCloudBoxList } = ptCtx;
212216

213217
const { addPolygon, deletePolygon } = usePolygon();
@@ -423,8 +427,7 @@ const PointCloudTopView: React.FC<IProps> = ({
423427

424428
pointCloud.camera.updateProjectionMatrix();
425429
pointCloud.render();
426-
427-
setZoom(zoom);
430+
debouncedSetZoom(zoom);
428431
syncTopviewToolZoom(currentPos, zoom, size);
429432
setAnnotationPos({ zoom, currentPos });
430433
});

0 commit comments

Comments
 (0)