Skip to content
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

feat(useScreenOrientation): new function #1526

Merged
merged 4 commits into from May 3, 2022

Conversation

michealroberts
Copy link
Contributor

@michealroberts michealroberts commented Apr 24, 2022

Description

This is a reactive composable that can relay the OrientationLockType, e.g., "primary-portrait" etc reactively, listening to the orientationchange event.

It is modelled around the Screen Orientation API MDN.

I'm not 100% convinced we need locking and unlocking, as this is almost a unused feature for most workflows, so please let me know if this is required.

Please view useScreenOrientation Loom Video Demonstration for demonstration.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@okxiaoliang4 okxiaoliang4 self-assigned this Apr 25, 2022
return new value `angle`
`lockOrientation`  return a promise
Only execute part of the logic when `isSupported = true`
okxiaoliang4
okxiaoliang4 previously approved these changes Apr 25, 2022
@okxiaoliang4
Copy link
Member

@okxiaoliang4 I'm not sure I like the use of the Promise reject in the lockOrientation() call ...

We could return Promise.resolve(). But I'm not sure which one is better.

@michealroberts
Copy link
Contributor Author

@okxiaoliang4 Thank you for the suggestions, just updated the documentation for all correct orientation types. It will need your review again! Thanks :)

@michealroberts
Copy link
Contributor Author

@okxiaoliang4 I'm not sure I like the use of the Promise reject in the lockOrientation() call ...

We could return Promise.resolve(). But I'm not sure which one is better.

I think the Promise.reject makes sense actually, it looks like oreintation.lock() returns a Promise, so yeh, I think you're right to return a rejection here.

@michealroberts
Copy link
Contributor Author

@okxiaoliang4 Also, could you set me to the assignee please as I was the one that opened the PR...

Copy link
Member

@okxiaoliang4 okxiaoliang4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can link to the type definition lib.dom.d.ts

@okxiaoliang4
Copy link
Member

Maybe we can link to the type definition lib.dom.d.ts

doesn't seem like a good idea.

@okxiaoliang4
Copy link
Member

Also, could you set me to the assignee please as I was the one that opened the PR

sure, I only want follow this pr

@michealroberts
Copy link
Contributor Author

Also, could you set me to the assignee please as I was the one that opened the PR

sure, I only want follow this pr

Awesome 🙏 thank you. Just so I have the blame on this one if there are issues, so new Issues can be assigned to me. :)

@antfu antfu merged commit e8c057c into vueuse:main May 3, 2022
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.

None yet

3 participants