Skip to content

fix(fiber): normalize viewport event prefixes#3758

Open
raashish1601 wants to merge 1 commit into
pmndrs:masterfrom
raashish1601:codex/event-prefix-viewport-coordinates
Open

fix(fiber): normalize viewport event prefixes#3758
raashish1601 wants to merge 1 commit into
pmndrs:masterfrom
raashish1601:codex/event-prefix-viewport-coordinates

Conversation

@raashish1601

Copy link
Copy Markdown

Summary

Canvas supports overriding pointer coordinate extraction via eventPrefix, but prefixes like client and page produce viewport/document coordinates instead of coordinates local to the canvas bounds. Those values were normalized directly against the canvas size, so an offset canvas produced shifted pointer coordinates and raycasts.

This normalizes clientX/clientY by the canvas bounds and pageX/pageY by the bounds plus window scroll. Offset-like prefixes keep their existing behavior.

Test Plan

  • npx jest packages/fiber/tests/events.test.tsx --runInBand
  • npx eslint packages/fiber/src/web/Canvas.tsx packages/fiber/tests/events.test.tsx
  • npx prettier --check packages/fiber/src/web/Canvas.tsx packages/fiber/tests/events.test.tsx
  • npm run -s typecheck
  • npm run -s build

@codesandbox-ci

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f216fa2:

Sandbox Source
example Configuration

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.

1 participant