react-native#PixelRatio JavaScript Examples

The following examples show how to use react-native#PixelRatio. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: dimension.js    From bluezone-app with GNU General Public License v3.0 5 votes vote down vote up
widthPercentageToDP = widthPercent => {
  const screenWidth = Dimensions.get('window').width;
  // Convert string input to decimal number
  const elemWidth = parseFloat(widthPercent);
  return PixelRatio.roundToNearestPixel((screenWidth * elemWidth) / 100);
}
Example #2
Source File: dimension.js    From bluezone-app with GNU General Public License v3.0 5 votes vote down vote up
heightPercentageToDP = heightPercent => {
  const screenHeight = Dimensions.get('window').height;
  // Convert string input to decimal number
  const elemHeight = parseFloat(heightPercent);
  return PixelRatio.roundToNearestPixel((screenHeight * elemHeight) / 100);
}
Example #3
Source File: FontSize.js    From MoviesDaily with MIT License 5 votes vote down vote up
export function normalize(size) {
  const newSize = size * scale;
  if (Platform.OS === "ios") {
    return Math.round(PixelRatio.roundToNearestPixel(newSize));
  } else {
    return Math.round(PixelRatio.roundToNearestPixel(newSize)) - 2;
  }
}
Example #4
Source File: Style.js    From react-native-tv-demo with MIT License 5 votes vote down vote up
pixelRatio = PixelRatio.get()
Example #5
Source File: SizeController.js    From react-native-vlc-media-player with MIT License 5 votes vote down vote up
pixelRatio = PixelRatio.get()
Example #6
Source File: NativePicker.android.js    From the-eye-knows-the-garbage with MIT License 5 votes vote down vote up
ratio = PixelRatio.get()