Skip to content

Instantly share code, notes, and snippets.

@zdienos
Forked from DeVoresyah/Scale.js
Created April 24, 2019 10:59
Show Gist options
  • Save zdienos/1bd59af45527a0f733508851b4674749 to your computer and use it in GitHub Desktop.
Save zdienos/1bd59af45527a0f733508851b4674749 to your computer and use it in GitHub Desktop.
Responsive Width & Height
import { Dimensions } from 'react-native';
const { width, height } = Dimensions.get('window');
const ScaleWidth = (scaleWidth) => {
const DESIGN_WIDTH = 180;
return (scaleWidth * width) / DESIGN_WIDTH
}
const ScaleHeight = (scaleHeight) => {
const DESIGN_HEIGHT = 180;
return (scaleHeight * height) / DESIGN_HEIGHT
}
export {
ScaleWidth,
ScaleHeight
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment