material 0.9.16 → 0.9.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/element.js +6 -1
- package/src/loader.js +78 -42
package/package.json
CHANGED
package/src/element.js
CHANGED
|
@@ -16,11 +16,16 @@ class Element {
|
|
|
16
16
|
|
|
17
17
|
// Apply additional attributes
|
|
18
18
|
for (const key in this.options) {
|
|
19
|
-
if (!['tag', 'container', 'html', 'text', 'id'].includes(key)) {
|
|
19
|
+
if (!['tag', 'container', 'html', 'text', 'id', 'data'].includes(key)) {
|
|
20
20
|
element.setAttribute(key, this.options[key])
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// Apply additional dataset
|
|
25
|
+
for (const key in this.options.data) {
|
|
26
|
+
element.setAttribute('data-' + key, this.options.data[key])
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
// Append to container if available
|
|
25
30
|
if (this.options.container) {
|
|
26
31
|
this.options.container.appendChild(element)
|
package/src/loader.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import emitter from './module/emitter'
|
|
2
|
+
|
|
1
3
|
class Loader {
|
|
2
4
|
static defaults = {
|
|
3
|
-
class: 'loader'
|
|
5
|
+
class: 'loader',
|
|
6
|
+
timeout: 17000
|
|
4
7
|
}
|
|
5
8
|
|
|
6
9
|
constructor (options) {
|
|
@@ -10,6 +13,7 @@ class Loader {
|
|
|
10
13
|
|
|
11
14
|
init (options) {
|
|
12
15
|
this.options = { ...Loader.defaults, ...options }
|
|
16
|
+
Object.assign(this, emitter)
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
build () {
|
|
@@ -21,51 +25,69 @@ class Loader {
|
|
|
21
25
|
this.element.appendChild(this.container)
|
|
22
26
|
|
|
23
27
|
const svg = `
|
|
24
|
-
<svg
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50">
|
|
29
|
+
<circle
|
|
30
|
+
class="base"
|
|
31
|
+
cx="25"
|
|
32
|
+
cy="25"
|
|
33
|
+
r="20"
|
|
34
|
+
fill="none"
|
|
35
|
+
stroke="#e5e7eb"
|
|
36
|
+
stroke-width="3"
|
|
37
|
+
/>
|
|
38
|
+
<circle
|
|
39
|
+
class="base"
|
|
40
|
+
cx="25"
|
|
41
|
+
cy="25"
|
|
42
|
+
r="16"
|
|
43
|
+
fill="none"
|
|
44
|
+
stroke="#e5e7eb"
|
|
45
|
+
stroke-width="2"
|
|
46
|
+
/>
|
|
47
|
+
|
|
48
|
+
<circle
|
|
49
|
+
class="outer"
|
|
50
|
+
cx="25"
|
|
51
|
+
cy="25"
|
|
52
|
+
r="20"
|
|
53
|
+
fill="none"
|
|
54
|
+
stroke-width="3"
|
|
55
|
+
stroke-linecap="round"
|
|
56
|
+
stroke-dasharray="62.8 62.8"
|
|
57
|
+
stroke-dashoffset="62.8">
|
|
58
|
+
<animateTransform
|
|
59
|
+
attributeName="transform"
|
|
60
|
+
type="rotate"
|
|
61
|
+
from="0 25 25"
|
|
62
|
+
to="360 25 25"
|
|
63
|
+
calcMode="spline"
|
|
64
|
+
keySplines="0.4, 0, 0.2, 1"
|
|
65
|
+
keyTimes="0;1"
|
|
66
|
+
dur="2s"
|
|
67
|
+
repeatCount="indefinite"
|
|
68
|
+
/>
|
|
69
|
+
</circle>
|
|
43
70
|
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
to="360 20 20"
|
|
51
|
-
calcMode="spline"
|
|
52
|
-
keySplines="0.4, 0, 0.2, 1"
|
|
53
|
-
keyTimes="0;1"
|
|
54
|
-
dur="2s"
|
|
55
|
-
repeatCount="indefinite" />
|
|
56
|
-
</path>
|
|
71
|
+
<circle
|
|
72
|
+
class="inner"
|
|
73
|
+
cx="25"
|
|
74
|
+
cy="25"
|
|
75
|
+
r="16"
|
|
76
|
+
fill="none"
|
|
57
77
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
78
|
+
stroke-width="2"
|
|
79
|
+
stroke-linecap="round"
|
|
80
|
+
stroke-dasharray="50.24 50.24"
|
|
81
|
+
stroke-dashoffset="50.24">
|
|
82
|
+
<animateTransform
|
|
62
83
|
attributeName="transform"
|
|
63
84
|
type="rotate"
|
|
64
|
-
from="0
|
|
65
|
-
to="360
|
|
66
|
-
dur="1.8s"
|
|
67
|
-
repeatCount="indefinite"
|
|
68
|
-
|
|
85
|
+
from="0 25 25"
|
|
86
|
+
to="360 25 25"
|
|
87
|
+
dur="1.8s"
|
|
88
|
+
repeatCount="indefinite"
|
|
89
|
+
/>
|
|
90
|
+
</circle>
|
|
69
91
|
</svg>`
|
|
70
92
|
|
|
71
93
|
this.container.innerHTML = svg
|
|
@@ -75,11 +97,25 @@ class Loader {
|
|
|
75
97
|
this.container.appendChild(this.text)
|
|
76
98
|
}
|
|
77
99
|
|
|
100
|
+
setText (text) {
|
|
101
|
+
this.text.innerHTML = text
|
|
102
|
+
}
|
|
103
|
+
|
|
78
104
|
show () {
|
|
79
105
|
this.element.classList.add('show')
|
|
106
|
+
|
|
107
|
+
clearTimeout(this.timeout)
|
|
108
|
+
|
|
109
|
+
if (this.options.timeout) {
|
|
110
|
+
this.timeout = setTimeout(() => {
|
|
111
|
+
this.hide()
|
|
112
|
+
this.emit('timeout')
|
|
113
|
+
}, this.options.timeout)
|
|
114
|
+
}
|
|
80
115
|
}
|
|
81
116
|
|
|
82
117
|
hide () {
|
|
118
|
+
clearTimeout(this.timeout)
|
|
83
119
|
this.element.classList.remove('show')
|
|
84
120
|
}
|
|
85
121
|
}
|