Skip to content

Commit 99c5a3e

Browse files
committed
add shades to files_bar
1 parent 470dbf4 commit 99c5a3e

File tree

4 files changed

+67
-28
lines changed

4 files changed

+67
-28
lines changed

algorithm/graph_search/dfs/desc.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121
"<a href='https://en.wikipedia.org/wiki/Depth-first_search'>Wikipedia</a>"
2222
],
2323
"files": {
24-
"11111111111": "",
25-
"22222222222": "",
26-
"33333333333": "",
27-
"44444444444": "",
28-
"55555555555": "",
29-
"66666666666": "",
3024
"tree": "Searching a tree",
3125
"all_paths": "Going through all possible paths without making any circuit",
3226
"weighted_graph": "DFS of Weighted Graph",

css/stylesheet.css

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ button {
5858
}
5959

6060
.btn:hover,
61-
button:hover {
61+
button:not([disabled]):hover {
6262
background: rgba(0, 0, 0, .15) !important;
6363
cursor: pointer;
6464
}
6565

6666
.btn.active,
6767
button.active {
68-
background: rgb(44, 44, 44);
68+
background: rgba(0, 0, 0, .28);
6969
}
7070

7171
.btn input,
@@ -138,7 +138,7 @@ nav h3 {
138138
}
139139

140140
.sidemenu #footer {
141-
border-top: 2px solid rgb(44, 44, 44);
141+
border-top: 2px solid rgba(0, 0, 0, .28);
142142
}
143143

144144
.sidemenu button {
@@ -181,7 +181,7 @@ section,
181181

182182
nav,
183183
section {
184-
border: 1px solid rgb(44, 44, 44);
184+
border: 1px solid rgba(0, 0, 0, .28);
185185
box-sizing: border-box;
186186
}
187187

@@ -227,7 +227,7 @@ section {
227227
z-index: 5;
228228
padding: 4px;
229229
font-size: 14px;
230-
background: rgb(44, 44, 44);
230+
background: rgba(0, 0, 0, .28);
231231
}
232232

233233
.module_wrapper > .wrapper {
@@ -258,11 +258,19 @@ section {
258258
height: 100%
259259
}
260260

261-
.files_bar > .button-left {
261+
.files_bar > button {
262+
width: 30px;
263+
}
264+
265+
.files_bar > button:disabled {
266+
background: rgba(0, 0, 0, .15);
267+
}
268+
269+
.files_bar > .btn-left {
262270
left: 0;
263271
}
264272

265-
.files_bar > .button-right {
273+
.files_bar > .btn-right {
266274
right: 0;
267275
}
268276

@@ -277,10 +285,23 @@ section {
277285
max-width: 80%;
278286
}
279287

288+
.files_bar > .wrapper.shadow-left {
289+
box-shadow: inset 16px 0 16px -16px rgba(0, 0, 0, .6);
290+
}
291+
292+
.files_bar > .wrapper.shadow-right {
293+
box-shadow: inset -16px 0 16px -16px rgba(0, 0, 0, .6);
294+
}
295+
296+
.files_bar > .wrapper.shadow-left.shadow-right {
297+
box-shadow: inset 16px 0 16px -16px rgba(0, 0, 0, .6),
298+
inset -16px 0 16px -16px rgba(0, 0, 0, .6);
299+
}
300+
280301
.explanation_container {
281302
top: 30px;
282303
height: 30px;
283-
background: rgb(44, 44, 44);
304+
background: rgba(0, 0, 0, .28);
284305
padding: 7px;
285306
font-size: 12px;
286307
}

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ <h3>
8989
</div>
9090
<div class="editor_container">
9191
<section class="files_bar">
92-
<button class="button-left">&lt;</button>
92+
<button class="btn-left"><i class="fa fa-angle-left" aria-hidden="true"></i></button>
9393
<div class="wrapper"></div>
94-
<button class="button-right">&gt;</button>
94+
<button class="btn-right"><i class="fa fa-angle-right" aria-hidden="true"></i></button>
9595
</section>
9696
<section class="explanation_container">
9797
<span id="explanation"></span>

js/script.js

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,35 +168,58 @@ var showFiles = function (category, algorithm, files) {
168168
}
169169
})(file, files[file]);
170170
}
171+
$('.files_bar > .wrapper').scroll();
171172
};
172-
$('.files_bar > .button-left').click(function () {
173-
var $parent = $('.files_bar > .wrapper');
174-
var clipWidth = $parent.width();
175-
var scrollLeft = $parent.scrollLeft();
176-
$($parent.children('button').get().reverse()).each(function () {
173+
$('.files_bar > .btn-left').click(function () {
174+
var $wrapper = $('.files_bar > .wrapper');
175+
var clipWidth = $wrapper.width();
176+
var scrollLeft = $wrapper.scrollLeft();
177+
$($wrapper.children('button').get().reverse()).each(function () {
177178
var left = $(this).position().left;
178179
var right = left + $(this).outerWidth();
179180
if (0 > left) {
180-
$parent.scrollLeft(scrollLeft + right - clipWidth);
181+
$wrapper.scrollLeft(scrollLeft + right - clipWidth);
181182
return false;
182183
}
183184
});
184185
});
185-
$('.files_bar > .button-right').click(function () {
186-
var $parent = $('.files_bar > .wrapper');
187-
var clipWidth = $parent.width();
188-
var scrollLeft = $parent.scrollLeft();
189-
$parent.children('button').each(function () {
186+
$('.files_bar > .btn-right').click(function () {
187+
var $wrapper = $('.files_bar > .wrapper');
188+
var clipWidth = $wrapper.width();
189+
var scrollLeft = $wrapper.scrollLeft();
190+
$wrapper.children('button').each(function () {
190191
var left = $(this).position().left;
191192
var right = left + $(this).outerWidth();
192193
console.log(left);
193194
console.log(right);
194195
if (clipWidth < right) {
195-
$parent.scrollLeft(scrollLeft + left);
196+
$wrapper.scrollLeft(scrollLeft + left);
196197
return false;
197198
}
198199
});
199200
});
201+
$('.files_bar > .wrapper').scroll(function () {
202+
var definitelyBigger = function (x, y) {
203+
return x > y + 2;
204+
};
205+
var $wrapper = $('.files_bar > .wrapper');
206+
var clipWidth = $wrapper.width();
207+
var $left = $wrapper.children('button:first-child');
208+
var $right = $wrapper.children('button:last-child');
209+
var left = $left.position().left;
210+
var right = $right.position().left + $right.outerWidth();
211+
if (definitelyBigger(clipWidth, right)) {
212+
var scrollLeft = $wrapper.scrollLeft();
213+
$wrapper.scrollLeft(scrollLeft + clipWidth - right);
214+
return;
215+
}
216+
var lefter = definitelyBigger(0, left);
217+
var righter = definitelyBigger(right, clipWidth);
218+
$wrapper.toggleClass('shadow-left', lefter);
219+
$wrapper.toggleClass('shadow-right', righter);
220+
$('.files_bar > .btn-left').attr('disabled', !lefter);
221+
$('.files_bar > .btn-right').attr('disabled', !righter);
222+
});
200223
var loadAlgorithm = function (category, algorithm) {
201224
if (checkLoading()) return;
202225
showAlgorithm(category, algorithm);
@@ -388,6 +411,7 @@ for (var i = 0; i < dividers.length; i++) {
388411
$second.css('left', percent + '%');
389412
x = e.pageX;
390413
tm.resize();
414+
$('.files_bar > .wrapper').scroll();
391415
}
392416
});
393417
$(document).mouseup(function (e) {

0 commit comments

Comments
 (0)