@keodesign/proportional-image-normalisation
v1.0.6
Published
Scales images to be visually proportionate based on aspect ratio.
Downloads
61
Readme
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"));