Skip to content

Instantly share code, notes, and snippets.

@corysimmons
Created February 19, 2018 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corysimmons/9877c809383533f8128ec8c49c90263c to your computer and use it in GitHub Desktop.
Save corysimmons/9877c809383533f8128ec8c49c90263c to your computer and use it in GitHub Desktop.
import { Dimensions, PixelRatio } from 'react-native'
const { width, height } = Dimensions.get(`window`)
export const vw = size => size * width / PixelRatio.getPixelSizeForLayoutSize(100) / PixelRatio.get()
export const vh = size => size * height / PixelRatio.getPixelSizeForLayoutSize(100) / PixelRatio.get()
export const vmin = Math.min(vw, vh)
export const vmax = Math.max(vw, vh)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment