forked from aliceui/aliceui.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathside.js
More file actions
30 lines (26 loc) · 916 Bytes
/
side.js
File metadata and controls
30 lines (26 loc) · 916 Bytes
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
define(function(require, exports, module) {
var $ = require('$');
exports.init = function() {
var titles = $('.content-area > .content > h2, h2.alice-module-title');
var doc = $(document);
if (titles.length <= 0) {
return;
}
$(window).scroll(function() {
var top = doc.scrollTop(), i;
if (top >= doc.height()- $(window).height() - 20) {
i = titles.length - 1;
} else {
for (i=0; i<titles.length; i++) {
if (top < titles.eq(i).offset().top - 20) {
break;
}
}
i--;
i = (i<0) ? 0 : i;
}
$('.side-area .side-highlight').removeClass('side-highlight');
$('.side-area > ul > li').eq(i).addClass('side-highlight');
});
};
});