-
Notifications
You must be signed in to change notification settings - Fork 0
/
strolch-wc-badge.html
93 lines (84 loc) · 2.22 KB
/
strolch-wc-badge.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
<!-- Components -->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-badge/paper-badge.html">
<link rel="import" href="../neon-animation/neon-animations.html">
<link rel="import" href="../neon-animation/neon-animation-runner-behavior.html">
<link rel="import" href="../neon-animation/animations/scale-up-animation.html">
<link rel="import" href="../neon-animation/animations/scale-down-animation.html">
<dom-module id="strolch-wc-badge">
<template>
<!-- Style -->
<style is="custom-style">
:host {
display: block;
position: relative;
z-index: 1;
}
paper-badge {
--paper-badge-background: var(--paper-indigo-200);
top: -7px !important;
right: -7px !important;
bottom: initial !important;
left: initial !important;
}
</style>
<!-- Content -->
<paper-badge id="badge" label="[[label]]" for="[[for]]"></paper-badge>
</template>
<script>
Polymer({
<!-- Settings -->
is: "strolch-wc-badge",
<!-- Behaviors -->
behaviors: [
Polymer.NeonAnimationRunnerBehavior
],
<!-- Properties -->
properties: {
for: {
type: String
},
hide: {
type: Boolean,
observer: "observeHide"
},
animationConfig: {
value: function() {
return {
"show": {
name: "scale-up-animation",
node: this.$.badge
},
"hide": {
name: "scale-down-animation",
node: this.$.badge
}
}
}
}
},
<!-- Observers -->
observeHide: function(newValue, oldValue) {
// show this element before the animation is started
this.hidden = false;
// animated to show/hide this badge
if(newValue) {
this.playAnimation("hide");
} else {
this.playAnimation("show");
}
},
<!-- Listeners -->
listeners: {
"neon-animation-finish": "onAnimationFinish"
},
onAnimationFinish: function() {
this.hidden = this.hide;
},
<!-- Function -->
ready: function() {
this.hidden = true;
}
});
</script>
</dom-module>