Skip to content

feat: prefer screen.orientation change events in useOrientation#2705

Open
louzhedong wants to merge 2 commits into
streamich:masterfrom
louzhedong:feat/orientation-change-event
Open

feat: prefer screen.orientation change events in useOrientation#2705
louzhedong wants to merge 2 commits into
streamich:masterfrom
louzhedong:feat/orientation-change-event

Conversation

@louzhedong

Copy link
Copy Markdown

Summary

Prefer screen.orientation.change when available and fall back to orientationchange.

Why

orientationchange is deprecated, while the Screen Orientation API exposes the modern event.

What changed

  • Updated the hook to subscribe to screen.orientation.change when possible
  • Kept the legacy orientationchange fallback
  • Added test coverage for both code paths

Verification

  • jest tests/useOrientation.test.ts
  • tsc --noEmit

@louzhedong louzhedong marked this pull request as ready for review June 8, 2026 12:13
@louzhedong

Copy link
Copy Markdown
Author

Pushed another update on top of this PR (b88f063) to keep the hook behavior aligned with the Screen Orientation API path.

Validation on the current patch:

  • eslint src/useOrientation.ts tests/useOrientation.test.ts
  • prettier --check --single-quote src/useOrientation.ts tests/useOrientation.test.ts
  • jest --runInBand --runTestsByPath tests/useOrientation.test.ts

The branch is up to date and the tests are green locally.

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