-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
340 lines (324 loc) · 17.1 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="./assets/favicon.ico" />
<meta name="title" content="Lazy-attr || Lazy page and Animations">
<meta name="description" content="Create beautiful animation on lazy (or not) elements. Make a lazy page (video, iframe and image) just with attributes.">
<meta name="keywords" content="html, js, css, animation, lazy, image, lazy-attr, embed, video, free, easy, attributes, iframe">
<meta name="robots" content="index, follow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="English">
<meta name="author" content="yoannchb">
<title>Lazy-attr || Lazy page and Animations</title>
<!-- LIB css + js-->
<script src="./dist/lazy-attr.cjs.js" type="text/javascript"></script>
<link href="./dist/lazy-attr-animation.css" rel="stylesheet"/>
<link href="./css/main.css" rel="stylesheet"/>
<style>
.lazyloaded{
filter: grayscale(100%);
}
</style>
</head>
<body>
<header>
<a href="https://github.com/yoannchb-pro/Lazy-attr" style="text-decoration: none;">
<h2 lazy-animation="slide-left" id="title">❤️ Lazy-attr.js</h2>
</a>
</header>
<section>
<!-- CODE -->
<div class="row">
<div class="col-code html-block">
<p style="color: whitesmoke">
Create a beautiful webpage with <b>lazy</b> image, iframe, video ... Moreover, use or create beautiful <b>animations</b> on lazy and not lazy elements on all browser.
<br>You can also use our animations included in the lib <a style="color: cyan" href="#toanimate">here</a>.
All of that in one lib and only with <b>html attributes</b> !
</p>
<p>
<span id="code-script" class="html-line"></span>
<span id="code-link" class="html-line"></span>
</p>
<p id="attr-script" style="color: #999999"></p>
</div>
</div>
<!-- Image lazy without reset -->
<div class="row b1" id="pointer">
<div class="col">
<p>
Example of an image which this lazy load and which when scrolling launches the animation even after having
already performed once the animation. Just add these attributes in your img. This image will make an animation on his parent
by selecting him with the attribute "lazy"pointer".
<code>lazy-src="https://picsum.photos/300/300?random=1" lazy-srcset="..." lazy-animation="zoomin" lazy-animation-pointer="#pointer" lazy-reset</code>
</p>
</div>
<div class="col">
<img alt="Random image" lazy-src="https://picsum.photos/300/300?random=1" lazy-animation="zoomin" lazy-animation-pointer="#pointer" lazy-reset>
</div>
</div>
<hr>
<!-- Image lazy one time animation -->
<div class="row">
<div class="col">
<img alt="Random image" lazy-animation-function="linear" lazy-animation-count="infinite"
lazy-src="https://picsum.photos/300/300?random=2" lazy-animation="rotate" lazy-animation-time="3">
</div>
<div class="col">
<p>
Example of an image which this lazy load and which when scrolling launches the animation but only once.
Then it is no longer taken into account. The animation is infinite in linear mode here.
<code>lazy-animation-function="linear" lazy-animation-count="infinite" lazy-src="https://picsum.photos/300/300?random=2" lazy-animation="rotate" lazy-animation-time="3"</code>
</p>
</div>
</div>
<hr>
<!-- Image lazy one time animation -->
<div class="row b1">
<div class="col">
<p>
Example of an image which this lazy load and which during scrolling several times.
Then it is no longer taken into account. I set a lazyloaded class to change the filter as grayscale.
<code>lazy-src="https://picsum.photos/300/300?random=3" class="lazyattr" lazy-animation="opacity" lazy-reset</code>
<code>
.lazyloaded{
filter: grayscale(100%);
}
</code>
</p>
</div>
<div class="col">
<img class="lazyattr" alt="Random image" lazy-reset lazy-src="https://picsum.photos/300/300?random=3"
lazy-animation="opacity" lazy-reset>
</div>
</div>
<hr>
<!-- Embed lazy -->
<div class="row">
<div class="col">
<iframe width="560" height="315" lazy-embed="https://www.youtube.com/embed/Y8Wp3dafaMQ?autoplay=0"
lazy-animation="shake"></iframe>
</div>
<div class="col">
<p>
Example of an embed video which launches during the click and which executes an animation during the scroll.
<code>lazy-embed="https://www.youtube.com/embed/Y8Wp3dafaMQ?autoplay=0" lazy-animation="shake"
lazy-size-width="300px" lazy-size-height="300px"
</code>
</p>
</div>
</div>
<hr>
<!-- Embed lazy with poster -->
<div class="row b1">
<div class="col">
<p>
Example of an image which this lazy load and which during scrolling several times.
Then it is no longer taken into account. This time, if the animation does not launch with a class but a style.
<code>lazy-reset lazy-animation="from-right"
lazy-embed="https://www.youtube.com/embed/Y8Wp3dafaMQ?autoplay=0"
lazy-poster="https://img.youtube.com/vi/Y8Wp3dafaMQ/hqdefault.jpg"</code>
</p>
</div>
<div class="col">
<iframe width="560" height="315" lazy-reset lazy-animation="slide-right"
lazy-embed="https://www.youtube.com/embed/Y8Wp3dafaMQ?autoplay=0"
lazy-poster="https://img.youtube.com/vi/Y8Wp3dafaMQ/hqdefault.jpg"></iframe>
</div>
</div>
<hr>
<!-- Lazy video -->
<div class="row" id="video-block">
<div class="col">
<video id="loaded" controls lazy-video="https://picsum.photos/560/315?random=10" lazy-src="./assets/flower.mp4"
lazy-animation="flip" lazy-animation-pointer="#video-block" type="video/mp4"></video>
</div>
<div class="col">
<p>
<strong id="video_stat">Video loading ...</strong>
Example of a video in lazy mode without preload and a poster. Lazy-video make the video in not preload mode and put a poster. We can know when the video is load thanks to 'lazy-loaded' event
<code>lazy-video="https://picsum.photos/560/315?random=10" lazy-src="./assets/flower.mp4"</code>
<code>
element.addEventListener('lazy-loaded', function(event){
document.querySelector('#video_stat').innerHTML = event.target.tagName + " loaded !";
})
</code>
</p>
</div>
</div>
<hr>
<!-- Lazy animation delay -->
<div class="row b1">
<div class="col">
<p>
Allows you to perform an animation with a gap delay between each frame here in the example below.
<code>lazy-animation-delay="time in seconde"</code>
</p>
</div>
</div>
<div class="row image-list">
<div class="col-delay">
<img alt="Random image" lazy-src="https://picsum.photos/300/300?random=4" lazy-animation="zoomin" lazy-reset/>
<img lazy-animation-delay="0.3" alt="Random image" lazy-src="https://picsum.photos/300/300?random=5"
lazy-animation="zoomin" lazy-reset/>
<img lazy-animation-delay="0.6" alt="Random image" lazy-src="https://picsum.photos/300/300?random=6"
lazy-animation="zoomin" lazy-reset/>
<img lazy-animation-delay="0.9" alt="Random image" lazy-src="https://picsum.photos/300/300?random=7"
lazy-animation="zoomin" lazy-reset/>
<img lazy-animation-delay="1.2" alt="Random image" lazy-src="https://picsum.photos/300/300?random=8"
lazy-animation="zoomin" lazy-reset/>
</div>
</div>
<hr>
<!-- Lazy background -->
<div class="row">
<div class="col">
<div class="card">
<div style="width: 300px; height: 200px; background-size: cover; background-position: center;"
lazy-background="https://picsum.photos/300/300?random=20"
class="lazy-skeleton"></div>
<div class="card-content" style="flex-direction: column">
<div style="display :flex">
<p class="lazy-skeleton" style="height: 1em; width: 7.5em; margin: 1em; margin-right: 10.4em"></p>
</div>
<p class="lazy-skeleton" style="height: 1em; width: 275px; margin: 0.5em"></p>
<p class="lazy-skeleton" style="height: 1em; width: 275px; margin: 0.5em"></p>
<p class="lazy-skeleton" style="height: 1em; width: 275px; margin: 0.5em"></p>
<p class="lazy-skeleton" style="height: 1em; width: 275px; margin: 0.5em"></p>
</div>
</div>
</div>
</div>
<div class="row b1">
<div class="col">
<p>
Make a lazy background just with lazy-background and the src !
<code>class="lazy-skeleton"
lazy-background="https://picsum.photos/300/300?random=20"</code>
</p>
</div>
</div>
<hr>
<!-- Test lazy list -->
<div class="row">
<div class="col-hoz">
<img alt="Random image" lazy-src="https://picsum.photos/300/300?random=4"
lazy-animation="opacity" lazy-size-width="300px" lazy-size-height="300px"/>
<img alt="Random image" lazy-src="https://picsum.photos/300/300?random=5"
lazy-animation="opacity" lazy-size-width="300px" lazy-size-height="300px"/>
<img alt="Random image" lazy-src="https://picsum.photos/300/300?random=6"
lazy-animation="opacity" lazy-size-width="300px" lazy-size-height="300px"/>
<img alt="Random image" lazy-src="https://picsum.photos/300/300?random=7"
lazy-animation="opacity" lazy-size-width="300px" lazy-size-height="300px"/>
<img alt="Random image" lazy-src="https://picsum.photos/300/300?random=8"
lazy-animation="opacity" lazy-size-width="300px" lazy-size-height="300px"/>
<img alt="Random image" lazy-src="https://picsum.photos/300/300?random=6"
lazy-animation="opacity" lazy-size-width="300px" lazy-size-height="300px"/>
<img alt="Random image" lazy-src="https://picsum.photos/300/300?random=7"
lazy-animation="opacity" lazy-size-width="300px" lazy-size-height="300px"/>
<img alt="Random image" lazy-src="https://picsum.photos/300/300?random=8"
lazy-animation="opacity" lazy-size-width="300px" lazy-size-height="300px"/>
<img alt="Random image" lazy-src="https://picsum.photos/300/300?random=5"
lazy-animation="opacity" lazy-size-width="300px" lazy-size-height="300px"/>
<img alt="Random image" lazy-src="https://picsum.photos/300/300?random=6"
lazy-animation="opacity" lazy-size-width="300px" lazy-size-height="300px"/>
<img alt="Random image" lazy-src="https://picsum.photos/300/300?random=7"
lazy-animation="opacity" lazy-size-width="300px" lazy-size-height="300px"/>
</div>
</div>
<hr>
<!-- Skeleton example -->
<div class="row">
<div class="col" style="height: auto">
<div class="lazy-skeleton skeleton-card"></div>
</div>
<div class="col" style="height: auto">
<div class="lazy-skeleton-corner skeleton-card"></div>
</div>
<div class="col" style="height: auto">
<div class="lazy-skeleton-top skeleton-card"></div>
</div>
</div>
<div class="row b1">
<div class="col">
<p>
Allows you to make skeleton loading animation just with a class.
<br>Dont forget width and height !
<br>Do not work on image so set up on the parent.
<code>class="lazy-skeleton" class="lazy-skeleton-corner" class="lazy-skeleton-top"</code>
</p>
</div>
</div>
<hr>
<!-- Animation examples -->
<div class="row">
<div class="col">
<div class="card" id="card">
<img id="toanimate" lazy-reset lazy-src="https://picsum.photos/300/200?random=9"
lazy-animation="corner-top-right" lazy-animation-pointer="#card">
<div class="card-content">
<p>Card</p>
</div>
</div>
<!--
<img style="border: thin solid #000;" id="toanimate" lazy"delay="0.3" alt="Random image" lazy-src="https://picsum.photos/300/300?random=9" lazy-animation="zoomin"/>
-->
</div>
<div class="col">
<p>
You will find below the list of events. You can create your own animation just by
replacing with a css class with an animation attribute. To add an animation just do:
<code id="code">lazy-animation="{animation name}"</code>
<select id="animation-select">
<option value="">--Choose animation--</option>
</select>
</p>
</div>
</div>
<footer class="b1">
<p lazy-animation="slide-bottom">By yoannchb ©</p>
</footer>
</section>
</body>
<!-- LOADED VIDEO -->
<script>
document.getElementById('loaded').addEventListener('lazy-loaded', function loaded(event){
document.querySelector('#video_stat').innerHTML = event.target.tagName + " loaded !";
});
</script>
<!-- CODE -->
<script>
let v = window.lazy().version;
document.querySelector('#title').innerHTML += " v" + v;
function toCodeHtml(t){
return t.replace(/\</gi, "<")
.replace(/\>/gi, ">")
.replace(/\[str\]/gi, "<span class='html-str'>")
.replace(/\[end-str\]/gi, "</span>")
.replace(/\[attr\]/gi, "<span class='html-attr'>")
.replace(/\[end-attr\]/gi, "</span>")
.split('[separate]');
}
document.querySelector('#code-script').innerHTML = toCodeHtml('<script [attr]src[end-attr]=[str]"https://unpkg.com/lazy-attr@' + v + '/dist/lazy-attr.js"[end-str] [attr]type[end-attr]=[str]"text/javascript"[end-str]><\/script>');
document.querySelector('#code-link').innerHTML = toCodeHtml('<link [attr]href[end-attr]=[str]"https://unpkg.com/lazy-attr@' + v + '/dist/lazy-attr-animation.css"[end-str] [attr]rel[end-attr]=[str]"stylesheet"[end-str]/>');;
document.querySelector('#attr-script').innerHTML = "<u>Attribute(s):</u> window.lazy().parameters";
document.querySelector('#attr-script').innerHTML += "<span style='display: block'><u>Global:</u> window.lazy()</span>";
</script>
<!-- ANIMATION LIST -->
<script>
const image = document.querySelector("#toanimate");
const select = document.querySelector("#animation-select");
const code = document.querySelector("#code");
const animationList = window.lazy().animations;
animationList.forEach(function(e){
let c = e+"";
select.innerHTML += "<option value='" + c + "'>" + e + "</option>";
});
select.onchange = function(){
let v = select.value;
code.innerHTML = 'lazy-animation="' + v + '"';
window.lazy().changeAnimation(image, v, true);
}
</script>
</html>