forked from pomber/paper-fab-speed-dial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaper-fab-speed-dial.html
113 lines (96 loc) · 2.61 KB
/
paper-fab-speed-dial.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
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="../iron-overlay-behavior/iron-overlay-behavior.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">
<link rel="import" href="../neon-animation/animations/cascaded-animation.html">
<!--
`paper-fab-speed-dial`
A floating action button flinging out related actions
@demo demo/index.html
-->
<dom-module id="paper-fab-speed-dial">
<template>
<style include="iron-flex iron-flex-alignment iron-flex-reverse">
:host {
@apply(--layout-vertical-reverse);
position: absolute;
bottom: 10px;
right: 10px;
@apply(--paper-fab-speed-dial);
}
:host ::content > .dropdown-content {
@apply(--layout-vertical-reverse);
}
:host ::content > .dropdown-content paper-fab {
margin: 0px 8px 10px 8px;
}
:host ::content > .dropdown-content[hidden] {
display: none;
}
</style>
<content></content>
</template>
<script>
Polymer({
is: 'paper-fab-speed-dial',
behaviors: [
Polymer.IronOverlayBehavior,
Polymer.NeonAnimationRunnerBehavior
],
properties: {
animationConfig: {
value: function(){
var menu = this._getDropdownContent();
var array = Array.prototype.slice.call(menu.children);
var reversed = Array.prototype.slice.call(array).reverse();
return {
'entry': {
name: 'cascaded-animation',
animation: 'scale-up-animation',
nodes: array
},
'exit': {
name: 'cascaded-animation',
animation: 'scale-down-animation',
nodes: reversed
}
}
}
}
},
listeners: {
'neon-animation-finish': '_onNeonAnimationFinish'
},
ready: function(){
var button = this._getTriggerElement();
if (button) {
this.listen(button, 'tap', 'toggle');
}
},
_renderOpened: function(){
this.cancelAnimation();
this.playAnimation('entry');
},
_renderClosed: function(){
this.cancelAnimation();
this.playAnimation('exit');
},
_onNeonAnimationFinish: function(){
if (this.opened) {
this._finishRenderOpened();
} else {
this._finishRenderClosed();
}
},
_getTriggerElement: function(){
var trigger = this.queryEffectiveChildren(':first-child');
return trigger.classList.contains('dropdown-content') ? undefined : trigger;
},
_getDropdownContent: function(){
return this.queryEffectiveChildren('.dropdown-content');
}
});
</script>
</dom-module>