SuidoViewertype
What attachSuidoView hands back.
Import it
import type { SuidoViewer } from "@johnmorrisdotca/suido/draw";
Definition
type SuidoViewer = {
get: () => SuidoView;
zoomIn: () => void;
zoomOut: () => void;
fit: () => void;
pan: (across: number, down: number) => void;
show: (cell: number) => void;
destroy: () => void;
};
Members
| Name | Type | Description |
|---|---|---|
get | () => SuidoView | The view as it is now. |
zoomIn | () => void | |
zoomOut | () => void | |
fit | () => void | Back to the whole board. |
pan | (across: number, down: number) => void | Move the view by a share of what it shows: |
show | (cell: number) => void | Move the view, if it has to, to show a piece (by the cell it was given in). |
destroy | () => void | Stop listening and put the drawing back as it was. |
Examples
import { SUIDO_5X5 } from "@johnmorrisdotca/suido/levels-5x5";
import { decodeLayout } from "@johnmorrisdotca/suido";
import { attachSuidoView, drawSuido } from "@johnmorrisdotca/suido/draw";
import type { SuidoViewer } from "@johnmorrisdotca/suido/draw";
const row = SUIDO_5X5[0];
const code = row[0];
const layout = decodeLayout(code)!;
const host = document.createElement("div");
document.body.append(host);
host.innerHTML = drawSuido(layout);
const svg = host.querySelector("svg")!;
const viewer: SuidoViewer = attachSuidoView(host,svg,layout);
console.log(viewer.get().zoom);
viewer.destroy();