-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
160 lines (159 loc) · 4.35 KB
/
index.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>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://kit.fontawesome.com/d57bfc784d.js" crossorigin="anonymous"></script>
<style type="text/css">
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
/* --image-comparison-slider-width: min(80vw, 768px); */
--image-comparison-slider-width: auto;
--image-comparison-slider-handle-width: 35px;
}
body {
font-family: Helvetica, sans-serif;
width: 100%;
min-height: 100vh;
/* padding-top: 2rem; */
display: flex;
align-items: center;
justify-content: center;
}
#image-comparison-slider {
position: relative;
width: var(--image-comparison-slider-width);
overflow: hidden;
border-radius: 0.5rem;
box-shadow: -7px 5px 16px 1px rgba(56, 86, 122, 0.6);
cursor: col-resize;
}
#image-comparison-slider img {
display: block;
width: var(--image-comparison-slider-width);
height: auto;
max-height: 80vh;
object-fit: cover;
pointer-events: none;
user-select: none;
}
#image-comparison-slider .img-wrapper {
position: absolute;
top: 0;
right: 0;
width: 50%;
height: 100%;
overflow: hidden;
z-index: 1;
transform: translateZ(0); /* This is in order to fix a Firefox bug, related to the 3D tilt effect */
/* transition: 0.25s cubic-bezier(.03,.98,.52,.99); */
}
#image-comparison-slider .img-wrapper img {
position: absolute;
top: 0;
right: 0;
height: 100%;
}
#image-comparison-slider .label {
position: absolute;
top: 1rem;
z-index: 3;
color: #fff;
background-color: rgba(0, 0, 0, 0.33);
border-radius: 0.25rem;
padding: 0.5rem 0.75rem;
font-size: 0.85rem;
text-align: center;
letter-spacing: 1px;
user-select: none;
opacity: 0;
transition: 0.25s cubic-bezier(0.68, 0.26, 0.58, 1.22);
}
#image-comparison-slider:hover .label {
opacity: 1;
}
#image-comparison-slider .label.label-before {
left: 1rem;
}
#image-comparison-slider .label.label-after {
right: 1rem;
background-color: #f95540;
}
#image-comparison-slider .handle {
position: absolute;
top: 0;
left: calc(50% - var(--image-comparison-slider-handle-width) / 2);
width: var(--image-comparison-slider-handle-width);
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
user-select: none;
z-index: 2;
/* transition: 0.25s cubic-bezier(.03,.98,.52,.99); */
}
#image-comparison-slider .handle-line {
width: 2px;
flex-grow: 1;
background-color: #fff;
}
#image-comparison-slider .handle-circle {
width: var(--image-comparison-slider-handle-width);
height: var(--image-comparison-slider-handle-width);
color: #fff;
border: 2px solid #fff;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: space-evenly;
background-color: rgba(0, 0, 0, 1);
}
@media (max-width: 768px) {
:root {
--image-comparison-slider-width: 90vw;
}
#image-comparison-slider img {
max-height: 90vh;
}
}
</style>
<title>Image Compare</title>
</head>
<body>
<div id="image-comparison-slider">
<img id="before" />
<div class="img-wrapper">
<img id="after" />
</div>
<span class="label label-before">Before</span>
<span class="label label-after">After</span>
<div class="handle">
<div class="handle-line"></div>
<div class="handle-circle">
<i class="fas fa-chevron-left"></i>
<i class="fas fa-chevron-right"></i>
</div>
<div class="handle-line"></div>
</div>
</div>
<script type="text/javascript">
window.addEventListener("load", function () {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const beforeimage = urlParams.get("o");
const afterimage = urlParams.get("n");
var before = document.getElementById("before");
var after = document.getElementById("after");
before.src = beforeimage;
after.src = afterimage;
});
</script>
<script type="text/javascript" src="/assets/image-comparison/vanilla-tilt.min.js"></script>
<script type="text/javascript" src="/assets/image-comparison/script.js"></script>
</body>
</html>