-
Notifications
You must be signed in to change notification settings - Fork 13
/
ex4.html
84 lines (68 loc) · 2.33 KB
/
ex4.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html>
<head>
<script language="javascript" src="dom-drag.js"></script>
<script language="javascript" src="ypSimpleScrollC.js"></script>
<style type="text/css">
#root {
position:absolute;
height:100px;
width:150px;
background-color:#F4F4F4;
border:1px solid #333;
font-family:verdana, sans-serif;
font-size:10px;
}
#handle {
margin:2px;
padding:2px;
width:142px;
color:white;
background-color:navy;
cursor:default;
}
#thumb {
position:absolute;
height:25px;
width:11px;
background-color:#eee;
border:1px outset #eee;
}
p {
margin-top:0px;
margin-bottom:1em;
}
</style>
<script language="javascript">
var theHandle, theRoot, theThumb, theScroll;
var thumbTravel, ratio;
theScroll = new ypSimpleScroll("scroll", 2, 19, 128, 75);
window.onload = function() {
theHandle = document.getElementById("handle");
theRoot = document.getElementById("root");
theThumb = document.getElementById("thumb");
theScroll.load();
Drag.init(theHandle, theRoot);
Drag.init(theThumb, null, 135, 135, 19, 71);
// the number of pixels the thumb can travel vertically (max - min)
thumbTravel = theThumb.maxY - theThumb.minY;
// the ratio between scroller movement and thumbMovement
ratio = theScroll.scrollH / thumbTravel;
theThumb.onDrag = function(x, y) {
theScroll.jumpTo(null, Math.round((y - theThumb.minY) * ratio));
}
}
</script>
</head>
<body>
<div id="root" style="left:20px; top:20px;">
<div id="handle">Handle</div>
<div id="thumb" style="left:135px; top:19px;"></div>
<div id="scrollContainer">
<div id="scrollContent">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exercitation ulliam corper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem veleum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel willum lunombro dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. </p>
</div>
</div>
</div>
</body>
</html>