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

Research: adding support for viewport units #2

Closed
kristerkari opened this issue Mar 31, 2018 · 1 comment
Closed

Research: adding support for viewport units #2

kristerkari opened this issue Mar 31, 2018 · 1 comment
Labels

Comments

@kristerkari
Copy link
Owner

Calculating styles dynamically makes it possible to add support for viewport units.

  • Viewport Width (vw) – A percentage of the full viewport width. 10vw will resolve to 10% of the current viewport width, or 48px on a phone that is 480px wide. The difference between % and vw is most similar to the difference between em and rem. A % length is relative to local context (containing element) width, while a vw length is relative to the full width of the browser window.
  • Viewport Height (vh) – A percentage of the full viewport height. 10vh will resolve to 10% of the current viewport height.
  • Viewport Minimum (vmin) – A percentage of the viewport width or height, whichever is smaller. 10vmin will resolve to 10% of the current viewport width in portrait orientations, and 10% of the viewport height on landscape orientations.
  • Viewport Maximum (vmax) – A percentage of the viewport width or height, whichever is larger. 10vmax will resolve to 10% of the current viewport height in portrait orientations, and 10% of the viewport width on landscape orientations. Sadly, and strangely, vmax units are not yet available on Internet Explorer or Edge.

The way that this would work is that css-to-react-native-transform would parse the values with units and enable a flag __viewportUnits: true. Those values would then during runtime be compared agains React Native's viewport and transformed to pixel values.

More info:
https://css-tricks.com/fun-viewport-units/

@kristerkari
Copy link
Owner Author

Done: #4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant