-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspinner.js
More file actions
47 lines (39 loc) · 925 Bytes
/
spinner.js
File metadata and controls
47 lines (39 loc) · 925 Bytes
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
/*
* Copyright © 2019 Danil Pismenny <danil@brandymint.ru>
*/
let tmpl = document.createElement('template');
// More spinner styles - https://tobiasahlin.com/spinkit/
//
tmpl.innerHTML = `
<style>
:host {
margin: auto;
display: block;
width: 50px;
height: 50px;
border: 3px solid rgba(0,0,0,.3);
border-radius: 50%;
border-top-color: #fff;
animation: dapi-spin 1s ease-in-out infinite;
}
:host([inline]) {
margin: 0;
display: inline-block;
height: 12px;
width: 12px;
}
:host([page]) {
margin: 50% auto;
}
@keyframes dapi-spin {
to { transform: rotate(360deg); }
}
</style>`;
customElements.define('dapi-spinner', class extends HTMLElement {
constructor() {
super(); // always call super() first in the constructor.
// Attach a shadow root to the element.
let shadowRoot = this.attachShadow({mode: 'open'});
shadowRoot.appendChild(tmpl.content.cloneNode(true));
}
} )