-
Notifications
You must be signed in to change notification settings - Fork 0
/
splitter.ts
69 lines (60 loc) · 2.21 KB
/
splitter.ts
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
module MOA {
export interface SplitterOptions {
initialTradWidth: number;
maxTradWidth: number;
minDocumentWidth: number;
}
export class Splitter {
container: SplitView;
isDragging = false;
minDocumentWidth: number;
$body: JQuery;
constructor(selector: string, options: SplitterOptions) {
this.$body = $("body");
this.minDocumentWidth = options.minDocumentWidth;
this.container = new SplitView(selector, options.initialTradWidth);
this.container.trad.$element.resizable({
autoHide: false,
handles: 'e',
maxWidth: options.maxTradWidth,
ghost: false,
resize: (e, ui: JQueryUI.ResizableUIParams) => {
this.container.calculateChildrenSize(ui.element.width());
this.container.resize();
},
create: (e, ui: JQueryUI.ResizableUIParams) => {
this.refresh();
$(".ui-resizable-handle").dblclick(() => {
this.container.toggle();
$(window).trigger("OnResizeMall");
});
},
start: (e, ui) => {
this.isDragging = true;
},
stop: (e, ui) => {
this.isDragging = false;
this.container.calculateChildrenSize(ui.element.width());
this.container.resize();
$(window).trigger("OnResizeMall");
}
});
$(window).resize(
<any>_.debounce(() => {
if (!this.isDragging)
this.refresh();
}, 100)
);
}
public refresh() {
ViewBase.runWithoutOverflow(() => {
var width = $(window).width()
if (width < this.minDocumentWidth)
width = this.minDocumentWidth;
this.container.updateSize(width)
this.container.calculateChildrenSize();
this.container.resize();
});
}
}
}