-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
95 lines (71 loc) · 3.02 KB
/
demo.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="dist/overlay.css">
<title>Overlay Image Preview</title>
</head>
<body>
<div class="container">
<h1 class="mt-3">Overlay Image Preview</h1>
<a target="_blank" href="https://github.com/geo6/overlay-image-preview">GitHub repository</a>
<hr>
<h2>Usage</h2>
<h3>Script</h3>
<pre class="bg-light my-3 p-3"><code><link
rel="stylesheet"
href="https://unpkg.com/@geo6/[email protected]/dist/overlay.css"
integrity="sha512-2oqbJitNlHq2zrkd0BILo0IJIOObgcWTgWo1hB0GiegrIOPhYXnWFU8JfTQmb9GiecGQYT0zqu8guaxSOKN6xw=="
crossorigin=""
></code></pre>
<pre class="bg-light my-3 p-3"><code><script
src="https://unpkg.com/@geo6/[email protected]/dist/overlay.js"
integrity="sha512-WiBgHAD/DPZRrHu5AEVco8lcU96uADvt6l0b2Rc+BRcSK0C+45LFk/+k/94CK4MB6mp2UyjkmdgFmdHvHRngdg=="
crossorigin=""
></script></code></pre>
<h3>Package dependency</h3>
<pre class="bg-light my-3 p-3"><code>npm install @geo6/overlay-image-preview</code></pre>
<hr>
<h2>Demo</h2>
<h3>Default overlay</h3>
<div class="mx-auto">
<a id="overlay" href="https://picsum.photos/536/354" type="button" class="btn btn-primary">
Show overlay
</a>
<pre class="text-light bg-dark my-3 p-3"><code>const overlay = new Overlay(myElement);
overlay.open();</code></pre>
</div>
<h3>Overlay with custom caption</h3>
<div class="mx-auto">
<a id="overlay-caption" href="https://picsum.photos/536/354" type="button" data-caption="Test Caption"
class="btn btn-primary mx-auto">
Show overlay with custom caption
</a>
<pre class="text-light bg-dark my-3 p-3"><code>const overlay = new Overlay(myElement, (element) => {
return element.dataset.caption;
});
overlay.open();</code></pre>
</div>
</div>
<script src="dist/overlay.js"></script>
<script>
(function () {
document.getElementById("overlay").addEventListener("click", (event) => {
event.preventDefault();
const overlay = new Overlay(event.currentTarget);
overlay.open();
});
document.getElementById("overlay-caption").addEventListener("click", (event) => {
event.preventDefault();
const overlay = new Overlay(event.currentTarget, (element) => {
return element.dataset.caption;
});
overlay.open();
});
})();
</script>
</body>
</html>