forked from iconic/SVGInjector
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathfallbacks.html
More file actions
executable file
·42 lines (37 loc) · 1.66 KB
/
fallbacks.html
File metadata and controls
executable file
·42 lines (37 loc) · 1.66 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SVGInjector Example: Fallbacks</title>
<style>
body {text-align: center; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; color: #3A3A3C;}
h2 {font-weight: normal; margin: 100px 0 10px;}
p {width: 400px; margin: 0 auto;}
.thumb-icon {
width: 64px;
height: 64px;
display: block;
margin: 25px auto;
}
.thumb-default {fill: #3A3A3C;}
.thumb-green {fill: #A6A93C;}
</style>
</head>
<body>
<h2>Global Fallback Setting</h2>
<p>This SVG will fallback to a PNG of the same name in the defined <code>pngFallback</code> directory.</p>
<img class="thumb-icon inject-me" data-src="assets/svg/thumb-up.svg" title="Thumb Up" alt="thumb">
<h2>Per-element Fallback Setting</h2>
<p>These SVGs will fallback to PNGs individually defined via the <code>data-fallback</code> attribute.</p>
<img class="thumb-icon thumb-default inject-me" data-src="assets/svg/thumb-up.svg" data-fallback="assets/png/thumb-up-default.png" title="Like it" alt="thumb">
<img class="thumb-icon thumb-green inject-me" data-src="assets/svg/thumb-up.svg" data-fallback="assets/png/thumb-up-green.png" title="Liked!" alt="thumb">
<script src="../dist/svg-injector.min.js"></script>
<script>
// Elements to inject
var mySVGsToInject = document.querySelectorAll('img.inject-me');
// Trigger the injection
new SVGInjector({forceFallbacks: true, pngFallback: 'assets/png'}).inject(mySVGsToInject);
</script>
</body>
</html>