Skip to content

Instantly share code, notes, and snippets.

View barayuda's full-sized avatar
🌎
Hi there 👋

Barayuda barayuda

🌎
Hi there 👋
View GitHub Profile
@yayanartha
yayanartha / RN-Scaling.js
Last active December 10, 2017 07:53
A proper way to keep the 'ideal size' of components and fonts across screen dimensions.
import { Dimensions } from 'react-native';
// Guideline sizes are based on standard ~5" screen mobile device
const guidelineBaseWidth = 350;
const guidelineBaseHeight = 680;
const scale = (size, screen = Dimensions.get('window')) => {
return screen.width / guidelineBaseWidth * size;
};
const verticalScale = (size, screen = Dimensions.get('window')) => {