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

Feature Request: Able to provide viewport sizes #149

Open
quicksilverr opened this issue Oct 12, 2022 · 0 comments
Open

Feature Request: Able to provide viewport sizes #149

quicksilverr opened this issue Oct 12, 2022 · 0 comments

Comments

@quicksilverr
Copy link

Hey, a slight suggestion @marudy

If we could give the option, to provide the sizes that we get from our designs directly to the functions that would be better.

I have written like a code snippet, which would explain better.

import _ from 'lodash';
import {
  widthPercentageToDP,
  heightPercentageToDP
} from 'react-native-responsive-screen';

const VIEWPORT_HEIGHT = 828;
const VIEWPORT_WIDTH = 414;
export const wp = (width: number): number => {
  const widthPercentage = (width / VIEWPORT_WIDTH) * 100;
  return _.ceil(widthPercentage);
};

export const hp = (height: number): number => {
  const heightPercentage = (height / VIEWPORT_HEIGHT) * 100;
  return _.ceil(heightPercentage);
};
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