-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
104 lines (95 loc) · 4.87 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
<!DOCTYPE HTML>
<html lang="en-EN">
<head>
<meta charset="UTF-8" />
<title>Vanilla Morph HTML Number</title>
<link rel="stylesheet" type="text/css" href="css/style.css?v=0.5.0" />
<script src="js/script.js?v=0.5.0"></script>
<script src="js/morphhtmlnumber.js?v=0.5.0"></script>
</head>
<body>
<h1>Vanilla Morph HTML Number</h1>
<p>
This script adds a counter animation to an element.<br />
No library dependency ✌️
</p>
<p>To use it, just load the JS file and follow our examples.</p>
<pre class="display-style"><script src="js/morphhtmlnumber.min.js?v=0.5.0"></script></pre>
<!-- Basic -->
<h2>Basic example</h2>
<p>Loading <span id="example-1">100</span>%</p>
<button id="reload-example-1">Relaunch</button>
<hr />
<script class="display-style">new morphHTMLNumber(document.getElementById('example-1'));</script>
<pre class="display-style"><span id="example-1"><strong>100</strong></span></pre>
<script>document.getElementById('reload-example-1').addEventListener('click', function(){
new morphHTMLNumber(document.getElementById('example-1'));
}, 1);</script>
<!-- Attributes -->
<h2>Example using attributes</h2>
<p>Loading <span id="example-2" data-finalvalue="142.42" data-morphtime="3000" data-morphisfloat="1"></span>%</p>
<button id="reload-example-2">Relaunch</button>
<hr />
<script class="display-style">new morphHTMLNumber(document.getElementById('example-2'));</script>
<pre class="display-style"><span id="example-2"
<strong>data-finalvalue</strong>="142.42"
<strong>data-morphtime</strong>="3000"
<strong>data-morphisfloat</strong>="1"></span></pre>
<script>document.getElementById('reload-example-2').addEventListener('click', function(){
new morphHTMLNumber(document.getElementById('example-2'));
}, 1);</script>
<!-- Arguments -->
<h2>Example using arguments</h2>
<p>Loading <span id="example-3"></span>%</p>
<button id="reload-example-3">Relaunch</button>
<hr />
<script class="display-style">new morphHTMLNumber({
el: document.getElementById('example-3'),
finalValue: 42.42,
time: 1000
});</script>
<pre class="display-style"><span id="example-3"><strong></strong></span></pre>
<script>document.getElementById('reload-example-3').addEventListener('click', function(){
new morphHTMLNumber({
el: document.getElementById('example-3'),
finalValue: 42.42,
time: 1000
});
}, 1);</script>
<!-- Reverse default -->
<h2>Reverse example with the default start value</h2>
<p>Loading <span id="example-4" data-morphisreverse="1">12</span>%</p>
<button id="reload-example-4">Relaunch</button>
<hr />
<script class="display-style">new morphHTMLNumber(document.getElementById('example-4'));</script>
<pre class="display-style"><span id="example-4"
<strong>data-morphisreverse</strong>="1">12</span></pre>
<script>document.getElementById('reload-example-4').addEventListener('click', function(){
new morphHTMLNumber(document.getElementById('example-4'));
}, 1);</script>
<!-- Reverse start -->
<h2>Reverse example with start value</h2>
<p>Loading <span id="example-5" data-startvalue="142">12</span>%</p>
<button id="reload-example-5">Relaunch</button>
<hr />
<script class="display-style">new morphHTMLNumber(document.getElementById('example-5'));</script>
<pre class="display-style"><span id="example-5"
<strong>data-startvalue</strong>="142">12</span></pre>
<script>document.getElementById('reload-example-5').addEventListener('click', function(){
new morphHTMLNumber(document.getElementById('example-5'));
}, 1);</script>
<!-- Starting only when visible -->
<h2>Starting only when visible</h2>
<p>Loading <span id="example-6">100</span>%</p>
<button id="reload-example-6">Relaunch</button>
<hr />
<script class="display-style">new morphHTMLNumber({el:document.getElementById('example-6'),waitUntilVisible: true});</script>
<pre class="display-style"><span id="example-6"><strong>100</strong></span></pre>
<script>document.getElementById('reload-example-6').addEventListener('click', function(){
new morphHTMLNumber({
el: document.getElementById('example-6'),
waitUntilVisible: true
});
}, 1);</script>
</body>
</html>