@keodesign/proportional-image-normalisation

1.0.6 • Public • Published

Proportional Image Normalisation

Scales images to be visually proportionate based on aspect ratio. An implementation of https://danpaquette.net/read/automatically-resizing-a-list-of-icons-or-logos-so-theyre-visually-proportional/

Class Parameters

  • @param {string} selector - An element selector for a set of elements to normalise
  • @param {int} widthBase - The width a square image would be scaled to
  • @param {int} scaleFactor - A balancing factor between scaling for height and width (i.e. aspect ratio bias). The default is generally visually balanced.
  • @param {Element} parentEl - A parent element to search for the selector. Defaults to document.

Sample Usage:

import { ProportionalImageNormalisation } from "@keodesign/proportional-image-normalisation";
proportionalImageNormalisation(".banners-home .banner-inner-image", 40, 0.525, document.querySelector("header"));

/@keodesign/proportional-image-normalisation/

    Package Sidebar

    Install

    npm i @keodesign/proportional-image-normalisation

    Weekly Downloads

    42

    Version

    1.0.6

    License

    MIT

    Unpacked Size

    6.35 kB

    Total Files

    6

    Last publish

    Collaborators

    • karlchiucinco
    • mark_keo