-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathlayout.js
119 lines (100 loc) · 4.41 KB
/
layout.js
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
'use strict';
let soundbarwidth = 100;
let lowerbarheight = document.getElementById("soundbar").clientHeight;
let upperbarheight = document.getElementById("uppertoolbar").clientHeight;
let winwidth = window.innerWidth;
let winheight = window.innerHeight;
let verticaldragbarWidth = document.getElementById("verticaldragbar").clientWidth;
let horizontaldragbarHeight = document.getElementById("horizontaldragbar").clientHeight;
let minimumDimension = 100;
function resize_widths(verticaldragbarX){
document.getElementById("leftpanel").style.width = verticaldragbarX + "px";
document.getElementById("righttophalf").style.left = verticaldragbarX + verticaldragbarWidth + "px";
document.getElementById("rightbottomhalf").style.left = verticaldragbarX + verticaldragbarWidth + "px";
document.getElementById("horizontaldragbar").style.left = verticaldragbarX + verticaldragbarWidth + "px";
document.getElementById("verticaldragbar").style.left = verticaldragbarX + "px";
canvasResize();
}
function resize_heights(horizontaldragbarY){
document.getElementById("leftpanel").style.height = (window.innerHeight - upperbarheight) + "px";
document.getElementById("verticaldragbar").style.height = (window.innerHeight - upperbarheight) + "px";
document.getElementById("righttophalf").style.height = horizontaldragbarY - upperbarheight + "px";
document.getElementById("rightbottomhalf").style.top = horizontaldragbarY + horizontaldragbarHeight + "px";
document.getElementById("horizontaldragbar").style.top = horizontaldragbarY + "px";
canvasResize();
}
function resize_all(e){
const smallmovelimit = 100;
const hdiff = window.innerWidth - winwidth;
let verticaldragbarX = parseInt(document.getElementById("verticaldragbar").style.left.replace("px",""));
if(hdiff > -smallmovelimit && hdiff < smallmovelimit){
verticaldragbarX += hdiff;
} else {
verticaldragbarX *= window.innerWidth/winwidth;
};
if ((verticaldragbarX <= minimumDimension)){
verticaldragbarX = minimumDimension;
} else if ((window.innerWidth - verticaldragbarX) < soundbarwidth){
verticaldragbarX = window.innerWidth - soundbarwidth;
};
resize_widths(verticaldragbarX);
const vdiff = window.innerHeight - winheight;
let horizontaldragbarY = parseInt(document.getElementById("horizontaldragbar").style.top.replace("px",""));
if(vdiff > -smallmovelimit && vdiff < smallmovelimit){
horizontaldragbarY += vdiff;
} else {
horizontaldragbarY *= window.innerHeight/winheight;
};
if ((horizontaldragbarY <= upperbarheight + minimumDimension)){
horizontaldragbarY = upperbarheight + minimumDimension;
} else if ((window.innerHeight - horizontaldragbarY) < (lowerbarheight + minimumDimension)){
horizontaldragbarY = window.innerHeight - (lowerbarheight + minimumDimension + 5);
};
resize_heights(horizontaldragbarY);
winwidth = window.innerWidth;
winheight = window.innerHeight;
};
function verticalDragbarMouseDown(e) {
e.preventDefault();
document.body.style.cursor = "col-resize";
window.addEventListener("mousemove", verticalDragbarMouseMove, false);
window.addEventListener("mouseup", verticalDragbarMouseUp, false);
};
function verticalDragbarMouseMove(e) {
if (e.pageX <= minimumDimension){
resize_widths(minimumDimension);
} else if ((window.innerWidth - e.pageX) > soundbarwidth){
resize_widths(e.pageX - 1);
} else {
resize_widths(window.innerWidth - soundbarwidth);
};
};
function verticalDragbarMouseUp(e) {
document.body.style.cursor = "";
window.removeEventListener("mousemove", verticalDragbarMouseMove, false);
};
function horizontalDragbarMouseDown(e) {
e.preventDefault();
document.body.style.cursor = "row-resize";
window.addEventListener("mousemove", horizontalDragbarMouseMove, false);
window.addEventListener("mouseup", horizontalDragbarMouseUp, false);
};
function horizontalDragbarMouseMove(e) {
if (e.pageY <= (upperbarheight + minimumDimension)) {
resize_heights(upperbarheight + minimumDimension);
} else if ((window.innerHeight - e.pageY) > (lowerbarheight + minimumDimension)){
resize_heights(e.pageY - 1);
} else {
resize_heights(window.innerHeight - lowerbarheight - minimumDimension);
}
};
function horizontalDragbarMouseUp(e) {
document.body.style.cursor = "";
window.removeEventListener("mousemove", horizontalDragbarMouseMove, false);
};
function reset_panels(){
resize_widths(Math.floor(window.innerWidth/2));
resize_heights(Math.floor(window.innerHeight/2));
winwidth = window.innerWidth;
winheight = window.innerHeight;
};