-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path13-custom-scrollbar.htm
139 lines (110 loc) · 4.67 KB
/
13-custom-scrollbar.htm
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html>
<head>
<title>Custom Scroll Bar</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<!-- LIBRARY FILES -->
<!-- <link rel="preload" href="image.png" as="image"> -->
<link rel="preload" href="basic/font/open-sans/OpenSans-Regular.ttf" as="font" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="basic/basic.min.css">
<script src="basic/basic.min.js" type="text/javascript" charset="utf-8"></script>
<script src="basic/scroll-bar.min.js" type="text/javascript" charset="utf-8"></script>
<style>
/*
body {
margin: 0px !important;
overflow: hidden !important;
}
*/
</style>
<script>
// VARIABLES
let box = null;
// First running function.
window.onload = function() {
const _BUTTON_HEIGHT = 50;
const _SHOWN_BUTTON_COUNT = 5;
const _TOTAL_BUTTON_COUNT = 10;
const _TOTAL_WIDTH = 200;
const _BOX_ROUND = 4;
// BOX: Main container
box = startBox({
width: _TOTAL_WIDTH,
height: _BUTTON_HEIGHT * _SHOWN_BUTTON_COUNT,
color: "transparent",
});
that.center();
// BOX: Scrollable content container
box.contentBox = startBox(0, 0, "100%", "100%", {
scrollY: 1,
round: _BOX_ROUND,
color: "whitesmoke",
});
// Create 10 Buttons
for (let i = 1; i <= _TOTAL_BUTTON_COUNT; i++) {
// BUTTON:
Button({
text: "Button " + i,
color: "rgba(255, 255, 255, 0.0)",
width: "100%",
height: _BUTTON_HEIGHT,
minimal: 1,
round: 0,
});
//that.setMotion("background-color 0.3s");
const _that = that;
that.on("mouseover", function(event) {
_that.color = "white";
_that.elem.style.borderTop = "1px solid rgba(0, 0, 0, 0.2)";
_that.elem.style.borderBottom = "1px solid rgba(0, 0, 0, 0.2)";
});
that.on("mouseout", function(event) {
_that.color = "rgba(255, 255, 255, 0.0)";
_that.elem.style.borderTop = "0px solid rgba(0, 0, 0, 0.2)";
_that.elem.style.borderBottom = "0px solid rgba(0, 0, 0, 0.2)";
});
// Set positions one below the other.
if (i > 1) {
that.aline(prevThat, "bottom");
} else {
that.left = 0;
that.top = 0;
}
} // end for
endBox(); // contentBox
// BOX: Border style
box.borderBox = Box(0, 0, "100%", "100%", {
color: "transparent",
border: 1,
borderColor: "rgba(0, 0, 0, 0.2)",
round: _BOX_ROUND,
});
// WHY: Using the border as a separate object prevents other objects from being affected.
// Because basic.js uses internal borders.
// SCROLL BAR:
box.scrollBar = ScrollBar({
scrollableBox: box.contentBox,
bar_border: 0,
bar_round: 2,
bar_borderColor: "rgba(0, 0, 0, 1)",
bar_width: 4,
bar_mouseOverWidth: 8,
bar_mouseOverColor: "black",
bar_opacity: 0.6,
bar_mouseOverOpacity: 0.8,
bar_padding: 3,
bar_color: "#141414",
neverHide: 0,
});
endBox(); // box
page.onResize(function() {
box.center();
});
};
</script>
</head>
<body>
<!-- HTML content -->
</body>
</html>