Skip to content

Instantly share code, notes, and snippets.

@nirsky
Last active July 24, 2017 10:20
Show Gist options
  • Save nirsky/17b95fc07332bcce64cdb6916a4f271e to your computer and use it in GitHub Desktop.
Save nirsky/17b95fc07332bcce64cdb6916a4f271e to your computer and use it in GitHub Desktop.
import { Dimensions } from 'react-native';
const { width, height } = Dimensions.get('window');
//Guideline sizes are based on standard ~5" screen mobile device
const guidelineBaseWidth = 350;
const guidelineBaseHeight = 680;
const scale = size => width / guidelineBaseWidth * size;
const verticalScale = size => height / guidelineBaseHeight * size;
const moderateScale = (size, factor = 0.5) => size + ( scale(size) - size ) * factor;
export {scale, verticalScale, moderateScale};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment