JSPM

fit-with-aspect-ratio

0.1.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 28
    • Score
      100M100P100Q49839F
    • License MIT

    Fit a original dimensions within a max/min boundaries while keeping its original aspect ratio

    Package Exports

    • fit-with-aspect-ratio

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fit-with-aspect-ratio) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    fit-with-aspect-ratio

    Fit a original dimensions within a max/min boundaries while keeping its original aspect ratio

    This package uses fit-box under the hood with additional changes, like ability to specify minimum dimensions to scale down.

    Installation

    yarn add fit-with-aspect-ratio

    Usage

    import fitWithAspectRatio from 'fit-with-aspect-ratio';
    
    const { width, height } = fitWithAspectRatio({
      originalWidth: 300,
      originalHeight: 400,
      maxWidth: 100,
      maxHeight: 30,
      minWidth: 10,
      minHeight: 10,
    })

    License

    The package is available as open source under the terms of the MIT License.