Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. imageWidth,
  2. imageHeight,
  3. ) {
  4. const screenWidth = window.innerWidth;
  5. const screenHeight = window.innerHeight;
  6. const screenRadio = screenWidth / screenHeight;
  7. const imageRadio = imageWidth / imageHeight;
  8. if (imageRadio > screenRadio) {
  9. return {
  10. width: screenWidth < imageWidth ? '100%' : `${imageWidth}px`,
  11. height: 'auto',
  12. };
  13. }
  14. return {
  15. width: 'auto',
  16. height: screenHeight < imageHeight ? '100%' : `${imageWidth}px`,
  17. };
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement