-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path6_3_scroll_trigger_animate_fullpage.html
137 lines (109 loc) · 4.08 KB
/
6_3_scroll_trigger_animate_fullpage.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<!-- <link rel="stylesheet" href="css/animate.css">-->
<style>
.fullpage {
visibility: hidden;
}
.slideup {
animation-name: slideup;
animation-duration: 1s;
animation-fill-mode: forwards;
visibility: visible;
position: fixed;
top: 0px;
}
.slideout {
animation-name: slideout;
animation-duration: 1s;
animation-fill-mode: forwards;
position: relative;
}
@keyframes slideup {
0% {
/* opacity: 0;*/
transform: translateY(70%);
}
100% {
/* opacity: 1;*/
transform: translateY(0%);
}
}
@keyframes slideout {
0% {
opacity: 1;
transform: translateY(80%);
}
100% {
opacity: 0;
transform: translateY(0%);
}
}
.fix_bg {
/* background-attachment: fixed;*/
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.fp {
padding: 0px;
}
</style>
</head>
<body>
<div class="container-fluid" style="height:100vh;background-color:dimgray"></div>
<div class="fp" style="height:100vh;">
<div class="fp fullpage fix_bg" style="height:100vh;width:100vw;background-image:url('assets/123.png');">
<h1>div1</h1>
</div>
</div>
<div class="container-fluid" style="height:100vh;width:100vw;z-index:100;background-color:dimgray">
<h1>div1.1</h1>
</div>
<div class="fp" style="height:100vh;">
<div class="fp fullpage fix_bg" style="height:100vh;width:100vw;background-image:url('assets/bg2.jpg')">
<h1>div2</h1>
</div>
</div>
<div class="fp" style="height:100vh;">
<div class="fp fullpage fix_bg" style="height:100vh;width:100vw;background-image:url('assets/123.png')">
<h1>div3</h1>
</div>
</div>
<div class="container-fluid" style="height:100vh;background-color:dimgray"></div>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"
integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"
integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous">
</script>
<script>
$(function () {
$(window).scroll(function () {
var winh = $(window).height();
var scrolled = $(window).scrollTop();
$(".fullpage").each(function () {
var objpos = $(this).offset().top;
if (scrolled > objpos - winh * 0.2 && scrolled < objpos + winh * 0.8) {
$(this).addClass("slideup");
}
if (scrolled > objpos + winh * 0.8) {
$(this).removeClass("slideup");
$(this).addClass("slideout");
}
if (scrolled == 0) {
$(this).removeClass("slideup");
}
});
});
});
</script>
</body>
</html>