-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
115 lines (104 loc) · 3.36 KB
/
test.html
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0058)file:///home/leif/Dokumente/source/js_playground/test.html -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>e layout sandbox</title>
<script type="text/javascript" src="dragdealer.js"></script>
<link rel="stylesheet" type="text/css" href="style/dragdealer.css"></head>
<script type="text/javascript">
function align_x_input(x) {
var b = this.document.getElementById("box");
var e = this.document.getElementById("e1");
var bw = b.style.width.split("px")[0];
var ew = e.style.width.split("px")[0];
var nx = (x * bw) - (ew / 2);
if (nx > (bw - ew))
nx = bw - ew;
else if (nx < 0)
nx = 0;
e.style.marginLeft = String(nx) + 'px';
}
function align_y_input(y) {
var b = this.document.getElementById("box");
var e = this.document.getElementById("e1");
var bh = b.style.height.split("px")[0];
var eh = e.style.height.split("px")[0];
var ny = (y * bh) - (eh / 2);
if (ny > (bh - eh))
ny = bh - eh;
else if (ny < 0)
ny = 0;
e.style.marginTop = String(ny) + 'px';
}
function align_x(x, y) {
var xi = document.getElementById('xalign');
align_x_input(x);
xi.value = x;
}
function align_y(x, y){
var yi = document.getElementById('yalign');
align_y_input(y);
yi.value = y;
}
window.onload = function()
{
new Dragdealer('x-scroller',
{
horizontal: true,
vertical: false,
animationCallback: align_x
});
new Dragdealer('y-scroller',
{
horizontal: false,
vertical: true,
animationCallback: align_y
});
}
</script>
<body>
<table>
<tbody>
<tr>
<td>
<div style="text-align:center">x-align</div>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
<div id="x-scroller" class="dragdealer rounded-cornered">
<div class="black-bar handle" style="width:30px"></div>
</div>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td id="box" style="width:500px;height:500px;vertical-align:top">
<div id="e1" style="background:green;width:50px;height:50px">green</div>
<!--<div id="box2" style="background:red;float:right">red</div>-->
</td>
<td style="width:30px;height:500px">
<div id="y-scroller" class="dragdealer rounded-cornered" style="width:100%;height:100%">
<div class="black-bar handle" style="width:100%;height:30px"></div>
</div>
</td>
<td>
<span style="text-align:center">y-align</span>
</td>
</tr>
</tbody>
</table>
<form id="i_align">Alignment
<input id="xalign" type="text" onKeyUp="align_x_input(this.value)" value="0.0"/>
<input id="yalign" type="text" onKeyUp="align_y_input(this.value)" value="0.0"/>
</form>
</body>
</html>