0.0.1 • Published 8 years ago

scale-size-at-width v0.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

scale-size-at-width

Get proportionately scaled size relative to base width.

Syntax

scaleSizeAtWidth(valueAtBaseWidth, baseWidth [, limits])

  • valueAtBaseWidth: (Number) desired element's size (in pixels) relative to base width
  • baseWidth: (Number) base width
  • limits - an optional object with minScaleWidth and maxScaleWidth properties. If set, the size will scale within allowed range and stay fixed beyond the limits.

Usage

var scaleSizeAtWidth = require('scale-size-at-width');

var size = scaleSizeAtWidth(200, 1280, {
  minScaleWidth: 1024,
  maxScaleWidth: 1920
});

In the above example, size will be:

  • 200px at width of 1280px and proportionately scaled between 1024px and 1920px
  • 160px at width of 1023px and less
  • 300px at width of 1921px and more

Install

npm install scale-size-at-width --save

Test

npm t

NOTE: Test requires beefy to be installed globally.

License

MIT, see LICENSE.md for details.