Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 1x 51x 51x 51x 51x | import { atom } from "nanostores";
import { createNanoEvents } from "nanoevents";
import { Slice } from "../slice";
import type { EditorContext } from "../editor-context";
export class SnapSlice extends Slice {
static readonly sliceKey = "snap";
$snap = atom<string>("1/16");
private events = createNanoEvents<{ snapChanged: (snap: string) => void }>();
constructor(ctx: EditorContext) {
super(ctx);
}
setSnap(snap: string): void {
this.$snap.set(snap);
this.events.emit("snapChanged", snap);
}
onSnapChanged(cb: (snap: string) => void): () => void {
return this.events.on("snapChanged", cb);
}
}
|