-
Notifications
You must be signed in to change notification settings - Fork 0
/
jviz-loading.html
153 lines (120 loc) · 3.67 KB
/
jviz-loading.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!--
@license
Copyright (c) 2016 The Jviz Project Authors. All rights reserved.
The Jviz Project is under the MIT License. See https://github.com/jviz/jviz/blob/dev/LICENSE
-->
<!-- Import elements -->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../jviz/jviz.html">
<link rel="import" href="../jviz-styles/jviz-styles.html">
<!-- Loading component -->
<dom-module id="jviz-loading">
<template>
<style>
/* Animation */
@keyframes loading_anim { 0%, 80%, 100% { background-color: rgba(255, 255, 255, 0); } }
/* Animation */
@keyframes loading_anim { 40% { background-color: rgba(255, 255, 255, 0); } }
/* Host style */
:host
{
/* Default color */
--jviz-loading-color: var(--jviz-blue);
/* Default loading width */
--jviz-loading-width: 10px;
/* Default loading space */
--jviz-loading-space: 15px;
/* Loading mixin */
--jviz-loading:
{
/* Dots */
border-radius: 100px;
width: var(--jviz-loading-width);
height: var(--jviz-loading-width);
background-color: var(--jviz-loading-color);
/* Animation */
animation: loading_anim 1.2s infinite ease-in-out;
animation-fill-mode: both;
/* Content */
content: '';
};
}
/* Host style */
:host
{
/* Import loading mixin */
@apply(--jviz-loading);
/* Display */
display: block;
/* Text */
text-indent: -9999em;
font-size: 10px;
/* Position */
position: relative;
transform: translateZ(0);
/* Animation */
animation-delay: -0.2s;
/* Margin */
margin-left: auto;
margin-right: auto;
margin-top: 0px;
}
/* Host before */
:host:before
{
/* Import loading mixin */
@apply(--jviz-loading);
/* Animation delay */
animation-delay: -0.4s;
/* Position */
left: calc(var(--jviz-loading-space) * -1);
position: absolute;
top: 0;
}
/* Host after */
:host:after
{
/* Import loading mixin */
@apply(--jviz-loading);
/* Position */
position: absolute;
left: var(--jviz-loading-space);
top: 0;
}
</style>
</template>
</dom-module>
<!-- Loading logic -->
<script>
//Loading component
var jviz_loading = { is: 'jviz-loading' };
//Properties
jviz_loading.properties = {};
jviz_loading.properties.color = { type: String, value: 'blue', reflectToAttribute: true, observer: '_update_color' };
jviz_loading.properties.width = { type: String, value: '8px', reflectToAttribute: true, observer: '_update_width' };
jviz_loading.properties.reflect = { type: Boolean, value: false, reflectToAttribute: true, observer: '_update_color' };
//Update the loading color
jviz_loading._update_color = function()
{
//Get the color variable
var color_variable = (this.reflect === true) ? 'var(--jviz-' + this.color + '-over)' : 'var(--jviz-' + this.color + ')';
//Update the color
this.customStyle['--jviz-loading-color'] = color_variable;
//Update the styles
this.updateStyles();
};
//Update the loading width
jviz_loading._update_width = function(value)
{
//Get the real value
value = parseInt(value.replace('px', '').replace('%', ''));
//Add the width value
this.customStyle['--jviz-loading-width'] = value + 'px';
//Update the dots space
this.customStyle['--jviz-loading-space'] = (value + 5) + 'px';
//Update the styles
this.updateStyles();
};
//Register the loading element
Polymer(jviz_loading);
</script>