UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) 751 B
import{jsx as s}from"react/jsx-runtime";import{useEffect as h,useRef as c}from"react";import y from"../GalleryPreLoader";const p=({url:r,setHeight:i=!1,position:l="center",isFullscreen:f=!1,leading:t=!1,fillMode:u="contain",onImageLoadHeightUpdate:a})=>{const o=c(null),e=c(null);h(()=>{!o.current||!e.current||!t||d(r)},[r]);const d=async g=>{if(i)try{const n=await y.load(g);e.current.style.height=n.height*e.current.clientWidth/n.width+"px",a&&a()}catch{}},m={backgroundImage:`url("${r}")`,backgroundSize:u,backgroundRepeat:"no-repeat",transition:t?"all 0.5s ease 0s":"none",backgroundPosition:l};return s("div",{ref:e,style:{width:"100%",height:t&&!f?"250px":"100%"},children:s("div",{ref:o,className:"gallery__img",style:m})})};export default p;