optically-size-images
Version:
Normalize the size of a group of images, optically, based on their aspect ratios
2 lines (1 loc) • 595 B
JavaScript
import i from"react";import f from"../../hooks/use-optical-image-size/index.js";import"../../../lib/index.js";const a=i.forwardRef((o,c)=>{const{src:l="",alt:n="",component:s="img",callback:p,...m}=o,{imgRef:t,ready:r,scale:y}=f(p),u={ref:i.useCallback(e=>{typeof t=="function"?t(e):t&&typeof t=="object"&&"current"in t&&t.current!==e&&(t.current=e),typeof c=="function"?c(e):c&&typeof c=="object"&&(c.current=e)},[t,c]),src:l,alt:n,...m,style:{"--optical-image-size":y,opacity:r?1:0,...o.style}};return i.createElement(s,u)});a.displayName="OpticallySizedImage";const O=a;export{O as default};