aboutsummaryrefslogtreecommitdiff
path: root/src/stores/NodeCollectionStore.ts
blob: ac4f515f106b6391e798f2c3f80d6efda33b23b7 (plain)
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
import { computed, observable, action } from "mobx";
import { NodeStore } from "./NodeStore";
import { Document } from "../fields/Document";

export class NodeCollectionStore extends NodeStore {

    @observable
    public Scale: number = 1;

    @observable
    public Nodes: NodeStore[] = new Array<NodeStore>();

    @observable
    public Docs: Document[] = [];

    @computed
    public get Transform(): string {
        return "translate(" + this.X + "px," + this.Y + "px) scale(" + this.Scale + "," + this.Scale + ")";
    }

    @action
    public AddNodes(stores: NodeStore[]): void {
        stores.forEach(store => this.Nodes.push(store));
    }
}