Canvas
<Clover.Canvas /><clover-canvas>43 kB loaded by a page with it alone to first view, gzipped83 kB loaded by a page with it alone to first view, styles included, gzipped
Clover’s own renderer for IIIF Canvases: images, video and sound on one pan and zoom surface.
<div style={{ height: }}>
<Clover.Canvas
iiifContent={url}
placeholder={}
controls={}
/>
</div><div style="height: px">
<clover-canvas
iiif-content="https://clover.iiif.library.northwestern.edu/mocks/standalone-canvas/canvas.json"
placeholder=""
controls="">
</clover-canvas>
</div>API reference
Draws the Presentation 4 Canvases you hand it, or loads one itself (iiifContentiiif-content), with
WebGL2, else Canvas2D. Inside a Root<clover-root>, given nothing to draw, it shows the Root’s current
view. It fills its parent, so give the parent a height.
It is experimental: its API may change in any release. A plain wheel scrolls the page,
unless options.gestures.scrollToZoom is on.
<clover-canvas>
Clover's renderer for images, video and sound. Alone, it draws what it is given: a IIIF resource by URL (a Manifest gives its first Canvas), image URLs, or Canvases as a property. Inside a clover-root, given nothing, the root's view. As tall as --clover-body-height (60vh) or its own style.
Examples
Images
Use src for images that are not on a Canvas: plain URLs, or IIIF image services with
isTiledImagetiled, tiled from their info.json.
<Clover.Canvas
src="https://iiif.dc.library.northwestern.edu/iiif/3/bcb98b9f-4c44-4fd0-bfa9-673fb904a2b1"
isTiledImage
label="The Vanishing Race - Navaho"
/><clover-canvas
src="https://iiif.dc.library.northwestern.edu/iiif/3/bcb98b9f-4c44-4fd0-bfa9-673fb904a2b1"
tiled
label="The Vanishing Race - Navaho"></clover-canvas>Several Canvases
Hand it the Canvases to show together, a spread say; which to show, and moving between
them, is yours. groupViews reads a Manifest’s behavior as the Viewer does.
const manifest = await Clover.toPresentation4(json);
const views = Clover.groupViews(
manifest.items,
Clover.resolveBehavior(manifest.behavior),
);
<Clover.Canvas
canvases={views[view].map((index) => manifest.items[index])}
label={manifest.label}
/>;<!-- A view of a Manifest: its first Canvas alone, or any view within a root. -->
<clover-root
iiif-content="https://clover.iiif.library.northwestern.edu/mocks/paged/manifest.json"
canvas-id="https://clover.iiif.library.northwestern.edu/mocks/paged/canvas/5"
>
<clover-canvas></clover-canvas>
</clover-root>Video and sound
A Canvas of video or sound plays in Clover’s own transport, with the captions it carries.
<Clover.Canvas iiifContent="https://clover.iiif.library.northwestern.edu/mocks/transcripts/manifest.json" /><clover-canvas
iiif-content="https://clover.iiif.library.northwestern.edu/mocks/transcripts/manifest.json"></clover-canvas>Annotations on a recording’s time
An annotation on a stretch of a recording (#t=) shows among its captions while that
stretch plays; one with a region too (xywh=…&t=…) follows what it marks, frame by frame.
Picking one, from the annotations menu or a list beside it, goes to its time.
<Clover.Canvas iiifContent="https://clover.iiif.library.northwestern.edu/mocks/rudolf-hess-nuremberg/manifest.json" /><clover-canvas
iiif-content="https://clover.iiif.library.northwestern.edu/mocks/rudolf-hess-nuremberg/manifest.json"></clover-canvas>Driving it
onReadyclover-ready hands you a handle (zoomBy, panBy, rotateBy, home, fitBounds and more) to
drive the view from controls of your own, and onViewportChange reports the region in view.
const canvas = useRef(null);
<Clover.Canvas
src={service}
isTiledImage
label={label}
onReady={(handle) => (canvas.current = handle)}
onViewportChange={(bounds) => setRegion(bounds)}
/>
<button onClick={() => canvas.current.zoomBy(2)}>Zoom in</button><clover-canvas
id="picture"
src="https://iiif.io/api/image/3.0/example/reference/918ecd18c2592080851777620de9bcb5-gottingen"
tiled
label="Göttingen's market square"
></clover-canvas>
<button type="button" id="zoom">Zoom in</button>
<script type="module">
const canvas = document.getElementById("picture");
canvas.addEventListener("clover-ready", ({ detail: { handle } }) => {
handle.on("viewport", () => setRegion(handle.getBounds()));
});
document
.getElementById("zoom")
.addEventListener("click", () => canvas.handle?.zoomBy(2));
</script>Canvas or Body
In a layout, place Body<clover-body> rather than Canvas<clover-canvas>: it draws the Root’s
view with this Canvas, and adds a height, your renderers, and the loading mark while the
Root loads. A Canvas<clover-canvas> alone in a Root<clover-root> shows the same view, without them.
<Clover.Root iiifContent={url}>
<Clover.Body />
</Clover.Root><clover-root
iiif-content="https://iiif.io/api/cookbook/recipe/0009-book-1/manifest.json">
<clover-body></clover-body>
</clover-root>Previous versions
Canvas<clover-canvas>replacesImage, and the Viewer’s player for video and sound.body,src,labelandinstanceIdcarry over.openSeadragonCallbackisonReadyclover-ready, which hands you a handle.openSeadragonConfigisoptions.options.