Skip to content

Instantly share code, notes, and snippets.

@rafaelmotta
Last active February 12, 2018 12:17
Show Gist options
  • Save rafaelmotta/1fc1d6e2c720c5578988b59d7bf867bf to your computer and use it in GitHub Desktop.
Save rafaelmotta/1fc1d6e2c720c5578988b59d7bf867bf to your computer and use it in GitHub Desktop.
React Native Scale
import {
Dimensions,
} from 'react-native';
const dimensions = Dimensions.get('window');
const { width, height } = dimensions;
const guidelineBaseWidth = 350;
const guidelineBaseHeight = 680;
export const scale = size => (width / guidelineBaseWidth) * size;
export const verticalScale = size => (height / guidelineBaseHeight) * size;
export const moderateScale = (size, factor = 0.5) => size + ((scale(size) - size) * factor);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment