Skip to content

components/ZoomableImage

import { … } from 'zidane-ui'ui/src/components/ZoomableImage.tsx

Components#

ZoomableImageComponent#

Renders an image that zooms toward the pointer, pans, and copies from its right-click menu. Fills its parent.

TypeScript
const ZoomableImage: ForwardRefExoticComponent<ZoomableImageProps & RefAttributes<ZoomableImageHandle>>
ZoomableImage props
NameTypeDescription
altstring

The image's alt text.

className?string

Extra classes on the viewport.

imgClassName?string

Classes on the <img>: its fit size and look.

imgRef?(element: HTMLImageElement | null) => void

Receives the <img> element (the lightbox animates it).

imgTestId?string

Test id on the <img>.

imgTitle?string

The image's tooltip.

onBackdropClick?() => void

A click on the viewport around the image (never the end of a drag).

onError?() => void

The image failed to load.

onLoad?(event: SyntheticEvent<HTMLImageElement>) => void

The image decoded.

onMenuOpenChange?(open: boolean) => void

The right-click menu opened or closed: an owner with keys of its own leaves them to the menu meanwhile.

srcstring

The image's address.

style?CSSProperties

Inline styles on the viewport.

ui/src/components/ZoomableImage.tsx:104

Constants#

MAX_REAL_SCALEConstant#

How far past its real size an image zooms.

TypeScript
const MAX_REAL_SCALE = 8

ui/src/components/zoom.ts:14

Interfaces#

ZoomableImageHandleInterface#

What the owner of a ZoomableImage drives it with.

TypeScript
interface ZoomableImageHandle
ZoomableImageHandle properties
NameTypeDescription
reset() => void

Back to fit.

zoomed() => boolean

Whether it is zoomed in now.

zoomIn() => void

One step in, around the centre.

zoomOut() => void

One step out, around the centre.

ui/src/components/ZoomableImage.tsx:49

ZoomableImagePropsInterface#

Props for ZoomableImage.

TypeScript
interface ZoomableImageProps
ZoomableImageProps properties
NameTypeDescription
altstring

The image's alt text.

className?string

Extra classes on the viewport.

imgClassName?string

Classes on the <img>: its fit size and look.

imgRef?(element: HTMLImageElement | null) => void

Receives the <img> element (the lightbox animates it).

imgTestId?string

Test id on the <img>.

imgTitle?string

The image's tooltip.

onBackdropClick?() => void

A click on the viewport around the image (never the end of a drag).

onError?() => void

The image failed to load.

onLoad?(event: SyntheticEvent<HTMLImageElement>) => void

The image decoded.

onMenuOpenChange?(open: boolean) => void

The right-click menu opened or closed: an owner with keys of its own leaves them to the menu meanwhile.

srcstring

The image's address.

style?CSSProperties

Inline styles on the viewport.

ui/src/components/ZoomableImage.tsx:61