Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 101x 96x 5x 5x 1x 1x 3x 1x | import { findBreakpoint } from "./findBreakpoint"; import { evalBreakpoints } from "./evalBreakpoints"; /** * Based an selected mode * and breakpoints range * generates size transformations * @param {'fill'|'width'|'height'|boolean} mode * @param {object} size * @param {array} breakpoints */ export function getResizeTransformation(mode, size, originalBP) { if (!mode || !size) { return {}; } const breakpoints = evalBreakpoints(originalBP) switch (mode) { case "fill": const computedSize = breakpoints ? { width: Math.floor(findBreakpoint(breakpoints, size.width)), height: Math.floor( (size.height / size.width) * findBreakpoint(breakpoints, size.width) ) } : { width: Math.floor(size.width), height: Math.floor(size.height) }; return { crop: "fill", ...computedSize }; case true: case "width": return { crop: "scale", width: Math.floor( breakpoints ? findBreakpoint(breakpoints, size.width) : size.width ) }; case "height": return { crop: "scale", height: Math.floor( breakpoints ? findBreakpoint(breakpoints, size.height) : size.height ) }; default: return {}; } } |