proportional-scale
TypeScript icon, indicating that this package has built-in type declarations

4.0.0 • Public • Published

proportional-scale

Travis (.org) npm NPM

Proportionally scales a rectangle. Pass it the width and height, along with a desired max-height/width or both. Get back the proportionally scaled dimensions along with a padding-bottom value: useful in creating scalable responsive image containers.

Getting started

yarn add proportional-scale
import { scale } from "proportional-scale";
 
const { width, height, paddingBottom, scale } = scale({
  width: 800,
  height: 600,
  maxWidth: 400
});
// => {
//   width: 400,
//   height: 300,
//   paddingBottom: "75%",
//   scale: 0.5
// };

Readme

Keywords

none

Package Sidebar

Install

npm i proportional-scale

Weekly Downloads

2,798

Version

4.0.0

License

MIT

Unpacked Size

19 kB

Total Files

15

Last publish

Collaborators

  • dzuc