Skip to content

Add throttling to pointer move event #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 17, 2024
Merged

Add throttling to pointer move event #164

merged 5 commits into from
Aug 17, 2024

Conversation

vinothpandian
Copy link
Owner

@vinothpandian vinothpandian commented Aug 17, 2024

Fixes #163

Add throttling to pointer move events in the Canvas component to optimize coordinate recording.

  • Modify packages/react-sketch-canvas/src/Canvas/index.tsx to add throttling to the handlePointerMove function using a custom useThrottledCallback function.
  • Add throttleTime to CanvasProps in packages/react-sketch-canvas/src/Canvas/types.ts with a default value of 20.
  • Add throttleTime to ReactSketchCanvasProps in packages/react-sketch-canvas/src/ReactSketchCanvas/types.ts with a default value of 20.
  • Add useThrottledCallback function in packages/react-sketch-canvas/src/Canvas/utils.tsx to throttle a callback function.
  • Update README.md to include documentation on the new throttleTime configuration option.
  • Add tests to verify throttling behavior in packages/tests/src/actions/throttling.spec.ts.
  • Write vitest tests for useThrottledCallback function in packages/react-sketch-canvas/src/Canvas/__test__/utils.test.tsx.

For more details, open the Copilot Workspace session.

Fixes #163

Add throttling to pointer move events in the Canvas component to optimize coordinate recording.

- Modify `packages/react-sketch-canvas/src/Canvas/index.tsx` to add throttling to the `handlePointerMove` function using a custom `useThrottledCallback` function.
- Add `throttleTime` to `CanvasProps` in `packages/react-sketch-canvas/src/Canvas/types.ts` with a default value of 20.
- Add `throttleTime` to `ReactSketchCanvasProps` in `packages/react-sketch-canvas/src/ReactSketchCanvas/types.ts` with a default value of 20.
- Add `useThrottledCallback` function in `packages/react-sketch-canvas/src/Canvas/utils.tsx` to throttle a callback function.
- Update `README.md` to include documentation on the new `throttleTime` configuration option.
- Add tests to verify throttling behavior in `packages/tests/src/actions/throttling.spec.ts`.
- Write vitest tests for `useThrottledCallback` function in `packages/react-sketch-canvas/src/Canvas/__test__/utils.test.tsx`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/vinothpandian/react-sketch-canvas/issues/163?shareId=XXXX-XXXX-XXXX-XXXX).
@vinothpandian vinothpandian changed the base branch from main to develop August 17, 2024 18:55
@vinothpandian vinothpandian merged commit ef93338 into develop Aug 17, 2024
1 check passed
@vinothpandian vinothpandian deleted the add-throttling branch August 17, 2024 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On pointer move is recording coordinates too frequent, adding a throttling to optimise
1 participant