forked from tjy-gitnub/tapple
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscroll.js
More file actions
59 lines (58 loc) · 1.93 KB
/
scroll.js
File metadata and controls
59 lines (58 loc) · 1.93 KB
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
let ph=window.innerHeight;
$(':root').css('--ph',`${ph}px`);
let g_percent=$('.scroll:not(.fun),.fx:not(.fun),.prog:not(.fun),.shine:not(.fun),.trans.s-b:not(.fun),.trans.b-s:not(.fun)');
let g_pfunc=$('.func');
let g_center=$('.lock,.fx.h,.trans.s-b,.trans.b-s');
let g_highlight=$('.highlight');
let g_show=$('.lock,.trans.s-b,.trans.b-s');
let g_stopcenter=$('.stop-center');
let my_scroll=(t)=>{null};
if($('html').scrollTop()==0){
$('#title').addClass('start');
}
$('body')[0].onscroll=function() {
let t=$('html').scrollTop();
if(t==0){
$('#title').addClass('start');
}else{
$('#title').removeClass('start');
}
for (let i = 0; i < g_percent.length; i++) {
const box = g_percent[i];
$(box).css('--scroll',`${(ph+t-box.offsetTop)/(ph+box.offsetHeight)*100}%`);
}
for (let i = 0; i < g_pfunc.length; i++) {
const box = g_pfunc[i];
$(box).css('--scroll',`${(4*(((ph+t-box.offsetTop)/(ph+box.offsetHeight)-0.5)**3)+0.5)*100}%`);
}
for (let i = 0; i < g_center.length; i++) {
const box = g_center[i];
$(box).css('--translate',`${ph+t-box.offsetTop-((ph+box.offsetHeight)/2)}px`);
}
for (let i = 0; i < g_highlight.length; i++) {
const box = g_highlight[i];
if(box.offsetTop-t<0.7*ph){
$(box).addClass('show');
}else{
$(box).removeClass('show');
}
}
for (let i = 0; i < g_show.length; i++) {
const box = g_show[i];
if(t<box.offsetTop+box.offsetHeight&&box.offsetTop-ph<t){
$(box).addClass('show');
}else{
$(box).removeClass('show');
}
}
for (let i = 0; i < g_stopcenter.length; i++) {
const box = g_stopcenter[i];
if(ph+t-box.offsetTop>=(ph+box.offsetHeight)/2){
$(box).addClass('stop');
}else{
$(box).removeClass('stop');
}
}
my_scroll(t);
}
$('html')[0].scroll(0,0);