Home Class Structure
Post
Cancel

Class Structure

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// listener controller for Joint graph
class Controller extends joint.mvc.Listener {
    get context() {
        const [ctx = null] = this.callbackArguments;
        return ctx;
    }
}

// view controller, controlling display of shortest path with listeners
class ViewController extends Controller {
    startListening() {
        const { paper } = this.context;

        // activate functions with certain listeners
        this.listenTo(paper, {
            'element:pointerdown': selectSource,
            'element:mouseenter': selectEnd,
            'element:mouseleave': hidePathOnMouseLeave,
        });
    }
}

// edit controller with listening
class EditController extends Controller {
    startListening() {
        const { graph, paper } = this.context;

        // adding links
        this.listenTo(graph, {
            'change:source': replaceLink,
            'change:target': replaceLink,
        });

        // adding nodes
        this.listenTo(paper, {
            'element:mouseenter': showElementTools,
            'element:mouseleave': hideElementTools,
            'blank:pointerdblclick': addElement
        });
    }
}
This post is licensed under CC BY 4.0 by the author.

Collegeboard - Classes

Collegeboard - Arrays