math-fit

1.0.1 • Public • Published

math-fit Build Status

Calculates the size and the position of a target to fit a container.

Installation

With npm do:

$ npm install math-fit --save

Install with component(1):

$ component install nk-components/math-fit

Usage

var fit = require('math-fit');
var target = {
  w: 200, // or width: 200
  h: 100 // or height: 100
};
var parent = {
  w: 200, // or width: 200
  h: 200 // or height: 200
};
 
var coverValues = fit(target, parent); // same as fit.cover(target, parent);
//
// >>
// {
//  left: float,
//  top: float,
//  width: float,
//  height: float,
//  scale: float
// }
 
var containValues = fit.contain(target, parent);

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i math-fit

Weekly Downloads

195

Version

1.0.1

License

MIT

Last publish

Collaborators

  • kewah