-
Notifications
You must be signed in to change notification settings - Fork 1
/
9_4_scrolled_opacity_zoom_move02.html
160 lines (135 loc) · 7.06 KB
/
9_4_scrolled_opacity_zoom_move02.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<style>
.earth-img {
position: fixed;
height: 100%;
object-fit: cover;
/* object-position: right;*/
opacity: 1;
}
/*
#bg-img {
background-image: url(images/Linpen2019_lg.jpg);
background-position: 0 0;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: 1;
}
*/
.transit-effect1 {
transition: bottom 1s;
}
</style>
<title>Hello, world!</title>
</head>
<body>
<!--SCENE I-->
<div style="height:300vh;">
<img src="images/Linpen2006.jpg" class="opa img-fluid earth-img" data-seq=1 style="z-index:99;">
<img src="images/Linpen2010.jpg" class="opa img-fluid earth-img" data-seq=2 style="z-index:98;">
<img src="images/Linpen2012.jpg" class="opa img-fluid earth-img" data-seq=3 style="z-index:97;">
<img src="images/Linpen2015.jpg" class="opa img-fluid earth-img" data-seq=4 style="z-index:96;">
<img src="images/Linpen2019.jpg" class="opa img-fluid earth-img" data-seq=5 style="z-index:95;">
</div>
<div style="height:100vh;background-color: #333"></div>
<!--SCENE II-->
<div class="row" style="position:relative">
<img src="assets/eagle.png" class="scrollable" data-top=10 data-top2=35
style="position:absolute;width:20%;left:10%;top:10%;transition:all ease x 1s; z-index:9999">
<div class="col-6 sticky-top" style="height:100vh;overflow:hidden;">
<img id="bg-img" src="images/Linpen2019_lg.jpg"
style="position:absolute;transform:translateX(0%);transform:translateY(0%);transition:all ease-in-out 1s;">
</div>
<div id="mapmove" class="col-6" style="background-color:#ccc;height:400vh;">
<div data-y="-50%" data-x="-10%" data-scale="2" class="maploc" style="height:100vh;background-color:#AAA">
</div>
<div data-y="-30%" data-x="-50%" data-scale="5" class="maploc" style="height:100vh;background-color:#BBB">
</div>
<div data-y="-60%" data-x="-20%" data-scale="10" class="maploc" style="height:200vh;background-color:#CCC">
</div>
</div>
</div>
<div style="height:100vh;background-color: #333"></div>
<!--SCENE III-->
<div class="" style="background-color:black;height:200vh;position:relative;overflow:hidden;">
<img class="scrollable" src="images/Linpen2019_lg.jpg" data-top=-20 data-top2=-50 data-left=-100 data-left2=-20
data-width=300 data-width2=400
style="position:absolute;width:300vw;top:-20%;left:-100%;transition:all ease-in-out 0.5s;">
<!-- <img class="scrollable" data-left=-10 data-left2=0 data-top=-10 data-top2=40 src="assets/grass_1.png" style="position:absolute;width:150vw;top:-10%;left:-10%;filter: grayscale(60%)">-->
</div>
<div style="height:100vh;background-color: #333"></div>
<!-- Optional JavaScript; choose one of the two! -->
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous">
</script>
<!-- Option 2: Separate Popper and Bootstrap JS -->
<!--
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-q2kxQ16AaE6UbzuKqyBE9/u/KzioAlnx2maXQHiDX9d4/zp8Ok3f+M7DPm+Ib6IU" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-pQQkAEnwaBkjpqZ8RU1fF1AKtTcHJwFl3pblpTlHXybJjHpMYo79HY3hIi4NKxyj" crossorigin="anonymous"></script>
-->
<script>
$(window).scroll(function () {
var scrolled = $(document).scrollTop();
var winh = $(window).height();
$(".opa").each(function () {
var opRange = $(this).parent().height() / 5;
$(this).css({
"opacity": ($(this).data("seq") * opRange - scrolled) / opRange
});
});
$(".maploc").each(function () {
var thispos = $(this).offset().top;
var thish = $(this).height();
if (scrolled >= thispos && scrolled < thispos + thish) {
// console.log("translate(" + $(this).data("x") + ", " + $(this).data("y") + ")");
$("#bg-img").css({
"transform": "translate(" + $(this).data("x") + ", " + $(this).data(
"y") + ") scale(" + $(this).data("scale") + ")"
});
}
});
if (scrolled < $("#mapmove").offset().top || scrolled > $("#mapmove").offset().top + $("#mapmove")
.height()) {
$("#bg-img").css({
"transform": "translate(0%, 0%) scale(1)"
});
}
$(".scrollable").each(function () {
var parent_pos = $(this).parent().offset().top;
var next_pos = $(this).parent().next().offset().top;
var parent_height = $(this).parent().height();
var parent_scrolled = scrolled - $(this).parent().offset().top;
if (parent_scrolled > 0 && scrolled < next_pos - winh) {
if ($(this).attr("data-left")) {
$(this).css('left', (($(this).data('left2') - $(this).data('left')) *
parent_scrolled / winh + $(this).data('left')) + '%');
}
if ($(this).attr("data-top")) {
$(this).css('top', (($(this).data('top2') - $(this).data('top')) *
parent_scrolled / winh + $(this).data('top')) + '%');
}
if ($(this).attr("data-width")) {
$(this).css('width', (($(this).data('width2') - $(this).data('width')) *
parent_scrolled / winh + $(this).data('width')) + '%');
}
}
});
});
</script>
</body>
</html>