@zzwing/react-image
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

A React Image Component

CircleCI codecov

DEMO

Edit v3r46pjql0

Image

  • Auto show the loading or error status of img
  • Can be previewed by Component Preview
  • Group by props group
  • Loadable by used IntersectionObserver
Props Desc Type Default
style -- Object
className -- String
width -- Number, String 100
height -- Number, String initial
src -- String
onClick -- Function
mask mask style when img hover Boolean true
group groupId, used to preview image in same group String default
objectFit img object-fit style String cover
imgProps img props Object
preview can be previewed Boolean true
onDelete delete icon callback Function
onError img onerror callback Function
onLoad img onload callback Function

Example

<Image src='1.jpg'/>
<Image src='1.jpg' style={{margin: '10px'}}/>
<Image src='1.jpg' width='120' height='120'/>
<Image src='1.jpg' objectFit='contains'/>
<Image src='1.jpg' imgProps={{alt: 'test', className: 'my-img-class'}}/>
<Image src='1.jpg' group='my-img-group-1'/> // PreviewApi/preview('1.jpg', [ /* group-img-list */ ])

PreviewApi

Func Desc Params
preview preview a image image: imgSrc or image index of list, list:Array: Images List
show open the previewer
hide close the previewer
destroy destroy the ins

Demo

preview a single image

PreviewApi.preview('1.jpg')

preivew an image in list

const list = ['1.jpg', '2.jpg', '3.jpg']
// use index
PreviewApi.preview(2, list)
// or use src
PreviewApi.preview('2.jpg', list)

Readme

Keywords

Package Sidebar

Install

npm i @zzwing/react-image

Weekly Downloads

4

Version

1.2.1

License

MIT

Unpacked Size

134 kB

Total Files

49

Last publish

Collaborators

  • zzwing