Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better scaling calculations #13

Open
timothyerwin opened this issue Jun 19, 2021 · 0 comments
Open

Better scaling calculations #13

timothyerwin opened this issue Jun 19, 2021 · 0 comments

Comments

@timothyerwin
Copy link

timothyerwin commented Jun 19, 2021

Hey,

I started off with this library but the tablet size was way off compared to the phone...I fixed it with this aspect ratio calculation...please consider updating this library

import { Dimensions, Platform, PixelRatio } from 'react-native';

const {
  width,
  height,
} = Dimensions.get('window');

export function normalize(size, multiplier = 2) {
  const scale = (width / height) * multiplier;

  const newSize = size * scale;

  return Math.round(PixelRatio.roundToNearestPixel(newSize));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant