-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path12_6_animate_storytelling6_bytransform.html
142 lines (124 loc) · 7.43 KB
/
12_6_animate_storytelling6_bytransform.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
<!doctype html>
<html lang="en">
<head>
<title>Parallax vertical</title>
<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/shadow.css">
<style>
</style>
<script src="https://code.jquery.com/jquery-3.2.1.js"></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>
</head>
<body>
<div class="" style="background-color:black;height:100vh;">
<!-- <div id="vline" style="position:absolute;background-color:crimsom;height:100vh;width:2px;top:-30vh;left:14vw;trasition:transform 0.5s;"></div> -->
</div>
<!-- <div id="vline2" style="position:fixed;background-color:crimsom;height:100vh;width:5px;top:-20vh;left:15vw;trasition:transform 0.5s;z-index:999;"></div> -->
<div class="innershadow1" style="background-color:gold;min-height:25vh;position:relative;">
<img src="novel/2/bg.jpg" style="width:100vw">
<img id="testing" src="novel/2/chair.png" class="scrollable dropshadow1" style="position:absolute;
width: 20%;
bottom: 0%;
left: 20%;
filter: grayscale(.2) blur(2px);">
<img src="novel/2/girl.png" class="scrollable dropshadow1" data-left1=40 data-left2=45 data-width1=30 data-width2=32 style="position:absolute;
width: 30%;
bottom: 0%;
left: 40%;
filter: blur(0px);
transition:left 0.5s">
</div>
<div class="innershadow1" style="background-color:gold;min-height:25vh;position:relative;">
<img src="novel/3/bg.jpg" style="width:100vw">
<img src="novel/3/girl.png" class="scrollable dropshadow1" data-left1=45 data-left2=50 data-width1=30 data-width2=35 data-bottom1=0 data-bottom2=-10 style="position:absolute;
width: 30%;
bottom: 0%;
left: 45%;
filter: blur(0px);
z-index: 10;trasition:bottom 0.5s;">
<img id="testing" src="novel/3/verre.png" class="scrollable dropshadow1"
data-top1=-10 data-top2=0 data-left1=25 data-left2=28
style="position:absolute;
width: 100%;
left: 25%;
top: -10%;
filter: grayscale(.2) blur(0px) opacity(0.8);
z-index: 10">
</div>
<div class="innershadow1" style="background-color:gold;min-height:25vh;position:relative;">
<img src="novel/4/bg.jpg" style="width:100vw">
<img src="novel/4/girl.png" class="scrollable dropshadow1" style="position:absolute;
width: 30%;
bottom: 0%;
left: 50%;
filter: blur(0px);">
<img id="testing" src="novel/4/debris.png" class="scrollable dropshadow1" data-bottom1=10 data-bottom2=-10
style="position:absolute;
width: 100%;
left: 25%;
bottom: 10%;
filter: grayscale(.2) blur(0px) opacity(0.8);
trasition:bottom 1.5s;">
</div>
<div class="innershadow1 horizontal" style="height:200vh;">
<!-- 問題在於,因為限定高度為100vh,所以寬度不定,在這樣的狀況下,若捲動100%也會錯-->
<img src="novel/9/bg.jpg" class="scrollable dropshadow1" data-left1=100 data-left2=-100
style="position:fixed;
top: 0px;
height: 100vh;
transform:translateX(100vw);
filter: blur(1px);">
<img src="novel/9/girl.png" class="scrollable dropshadow1" data-left1=80 data-left2=-80
style="position:fixed;
height: 50vh;
transform:translateX(100vw);
bottom: 0%;
filter: grayscale(.2) blur(0px) opacity(0.8);">
</div>
<div class="container-fluid" style="background-color:black;min-height: 200vh"></div>
<div class="container-fluid" style="background-color:black;min-height: 200vh"></div>
<script>
$(document).ready(function() {
$(window).scroll(function() {
var scrolled = $(window).scrollTop();
var winh = $(window).height();
// $("#vline").css("transform", "translateY(" + scrolled / winh * 100 + "vh)");
// $("#vline2").css("transform", "translateY(" + scrolled / scrolled * 100 - 30 + "vh)");
$(".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 - parent_pos + winh * 0.25;
if ($(this).parent().hasClass("horizontal")) {
if ($(this).attr("data-left1")) {
$(this).css('transform', "translateX(" + (($(this).data('left2') - $(this).data('left1')) * parent_scrolled / parent_height + $(this).data('left1')) + 'vw)');
}
} else {
if (scrolled > parent_pos - winh * 0.25 && scrolled < next_pos - winh * 0.25) {
if ($(this).attr("data-left1")) {
$(this).css('left', (($(this).data('left2') - $(this).data('left1')) * parent_scrolled / parent_height + $(this).data('left1')) + '% ');
}
if ($(this).attr("data-top1")) {
$(this).css('top', (($(this).data('top2') - $(this).data('top1')) * parent_scrolled / parent_height + $(this).data('top1')) + '%');
}
if ($(this).attr("data-width1")) {
$(this).css('width', (($(this).data('width2') - $(this).data('width1')) * parent_scrolled / parent_height + $(this).data('width1')) + '%');
}
if ($(this).attr("data-height1")) {
$(this).css('height', (($(this).data('height2') - $(this).data('height1')) * parent_scrolled / parent_height + $(this).data('height1')) + '%');
}
if ($(this).attr("data-bottom1")) {
$(this).css('bottom', (($(this).data('bottom2') - $(this).data('bottom1')) * parent_scrolled / parent_height + $(this).data('bottom1')) + '%');
}
}
}
});
// console.log($("#testing").offset().left/$(window).width());
});
});
</script>
</body>
</html>