dzucconi / proportional-scale

Proportionally scales width and height values

Home Page:https://www.npmjs.com/package/proportional-scale

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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
// };

About

Proportionally scales width and height values

https://www.npmjs.com/package/proportional-scale

License:MIT License


Languages

Language:TypeScript 97.2%Language:JavaScript 2.8%