-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
213 lines (195 loc) · 8.15 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@5.3.0/dist/photoswipe.css">
<link rel="stylesheet" href="./photoswipe-dynamic-caption-plugin.css">
<!-- demo styles, ignore em-->
<style>
body {
margin: 0;
padding: 0;
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;
font-size: 14px;
line-height: 20px;
background: #eee;
}
h1 {
margin: 0;
padding: 50px 50px 30px 50px;
font-size: 26px;
line-height: 1.3;
}
.pswp-gallery__item {
margin: 0 4px 4px 0;
}
.pswp-gallery__item img {
display: block;
}
.pswp-gallery {
max-width: 650px;
padding: 0 50px 50px;
background: #eee;
position: relative;
display: flex;
flex-wrap: wrap;
}
.pswp__dynamic-caption {
color: #fff;
width: 100%;
}
.pswp__dynamic-caption a {
color: #fff;
text-decoration: underline;
}
</style>
</head>
<body>
<h1><a href="https://github.com/dimsemenov/photoswipe-dynamic-caption-plugin">Dynamic caption plugin</a> for <a href="https://photoswipe.com">PhotoSwipe v5</a></h1>
<div class="pswp-gallery" id="gallery">
<div class="pswp-gallery__item">
<a
href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/2/img-2500.jpg"
data-pswp-width="1669"
data-pswp-height="2500"
target="_blank">
<img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/2/img-200.jpg" alt="Demo image 1" />
</a>
<div class="pswp-caption-content"><b>Lorem ipsum dolor (1933)</b><br>Color photograph<br>12 x 10</div>
</div>
<div class="pswp-gallery__item">
<a
href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/3/img-2500.jpg"
data-pswp-width="2500"
data-pswp-height="1666"
target="_blank">
<img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/3/img-200.jpg" alt="Demo image 2" />
</a>
<div class="pswp-caption-content">
<b>Vivamus elementum (2016)</b><br>ullamcorper ultricies nisi, nam eget dui, etiam rhoncus, maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero<br>32 x 37 x 1.8 inches
</div>
</div>
<div class="pswp-gallery__item">
<a
href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/4/img-2500.jpg"
data-pswp-width="2500"
data-pswp-height="1667"
target="_blank">
<img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/4/img-200.jpg" alt="Demo image 3" />
</a>
<div class="pswp-caption-content">
<b>Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. (2008)</b><br>quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem, ut libero venenatis faucibus.
</div>
</div>
<div class="pswp-gallery__item">
<a
href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/5/img-2500.jpg"
data-pswp-width="2500"
data-pswp-height="1668"
target="_blank">
<img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/5/img-200.jpg" alt="Demo image 4" />
</a>
<div class="pswp-caption-content">
Short caption with <a href="https://example.com" target="_blank">the link</a>.
</div>
</div>
<div class="pswp-gallery__item">
<a
href="https://dummyimage.com/400x400/555/fff/?text=400x400"
data-pswp-width="500"
data-pswp-height="500"
target="_blank">
<img src="https://dummyimage.com/100x100/555/fff/" alt="Demo image 5" />
</a>
<div class="pswp-caption-content">
Small image
</div>
</div>
<div class="pswp-gallery__item">
<a
href="https://dummyimage.com/200x1000/555/fff/"
data-pswp-width="200"
data-pswp-height="1000"
target="_blank">
<img src="https://dummyimage.com/20x100/555/fff/" alt="Tall image" />
</a>
</div>
<div class="pswp-gallery__item">
<a
href="https://dummyimage.com/1000x200/555/fff/"
data-pswp-width="1000"
data-pswp-height="200"
target="_blank">
<img src="https://dummyimage.com/100x20/555/fff/" alt="Wide image" />
</a>
</div>
<div class="pswp-gallery__item">
<a
href="https://dummyimage.com/1200x500/555/fff/?text=no+caption"
data-pswp-width="1200"
data-pswp-height="500"
target="_blank">
<img src="https://dummyimage.com/240x100/555/fff/" alt="" />
</a>
</div>
<div class="pswp-gallery__item">
<a
href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/6/img-2500.jpg"
data-pswp-width="2500"
data-pswp-height="1667"
target="_blank">
<img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/6/img-200.jpg" alt="Demo image 8" />
</a>
<div class="pswp-caption-content">
<b>Long caption</b><br>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum<br>Lorem Ipsum
</div>
</div>
<div class="pswp-gallery__item">
<a
href="https://dummyimage.com/1500x1500/555/fff/?text=1500x1500"
data-pswp-width="1500"
data-pswp-height="1500"
target="_blank">
<img src="https://dummyimage.com/100x100/555/fff/" alt="Large 1500x1500 square" />
</a>
</div>
<div class="pswp-gallery__item">
<a
href="https://dummyimage.com/600x1500/555/fff/?text=600x1500"
data-pswp-width="600"
data-pswp-height="1500"
target="_blank">
<img src="https://dummyimage.com/60x150/555/fff/" alt="Demo image 9" />
</a>
<div class="pswp-caption-content">
<b>Another long caption</b><br>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum<br>Lorem Ipsum
</div>
</div>
</div>
<script type="module">
import PhotoSwipeLightbox from 'https://cdn.jsdelivr.net/npm/photoswipe@5.3.0/dist/photoswipe-lightbox.esm.js';
import PhotoSwipeDynamicCaption from './photoswipe-dynamic-caption-plugin.esm.js';
const smallScreenPadding = {
top: 0, bottom: 0, left: 0, right: 0
};
const largeScreenPadding = {
top: 30, bottom: 30, left: 0, right: 0
};
const lightbox = new PhotoSwipeLightbox({
gallerySelector: '#gallery',
childSelector: '.pswp-gallery__item',
// optionaly adjust viewport
paddingFn: (viewportSize) => {
return viewportSize.x < 700 ? smallScreenPadding : largeScreenPadding
},
pswpModule: () => import('https://cdn.jsdelivr.net/npm/photoswipe@5.3.0/dist/photoswipe.esm.js')
});
const captionPlugin = new PhotoSwipeDynamicCaption(lightbox, {
mobileLayoutBreakpoint: 700,
type: 'auto',
mobileCaptionOverlapRatio: 1
});
lightbox.init();
</script>
</body>
</html>