Skip to content

Instantly share code, notes, and snippets.

@mutablestudio
Last active February 22, 2019 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mutablestudio/9e0ca3b1199b8c1706895b8f635345cd to your computer and use it in GitHub Desktop.
Save mutablestudio/9e0ca3b1199b8c1706895b8f635345cd to your computer and use it in GitHub Desktop.
react-native size class func
export const isMediumHeight = height < 750 && height >= 600
export const isSmallHeight = width < 600
export const setImageScale = (size, type) => {
console.log(`smallImageScale height ${height} size ${size} type ${type}`)
switch(true) {
case isMediumHeight:
reduceBy = type === 'large' ? .55 : .85
return Math.round(size * reduceBy);
case isSmallHeight:
reduceBy = type === 'large' ? .25 : .65
return Math.round(size * reduceBy);
default:
return size;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment