Reference · Rolls and exact odds
mountDiefunction
Put one die in an element. Only the element is needed: a die of 6 sides that rolls.
Import it
import { mountDie } from "@johnmorrisdotca/korokoro";
Definition
function mountDie(target: HTMLElement, options?: DieOptions): DieHandle
Parameters
| Name | Type | Description |
|---|---|---|
target | HTMLElement | The HTMLElement that owns the native interface. |
options (optional) | DieOptions | Native settings and callbacks for this mounted interface. |
Returns
DieHandle
The native mounted handle, including controls and destroy() cleanup.
Examples
import { mountDie } from "@johnmorrisdotca/korokoro";
const box = document.createElement("div");
document.body.append(box);
const die = mountDie(box, { sides: 20, size: "large", onRoll: (face) => console.log(face) });
die.roll();