forked from dreammmr/paper-fab-menu
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpaper-fab-menu.html
237 lines (206 loc) · 8.45 KB
/
paper-fab-menu.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<!--
@author Arshak Khachatrian (<a href="mailto:[email protected]">[email protected]</a>)
@website http://spacee.xyz
@updateDate May 14, 2016
**********
*
* *** PAPER FAB MENU ***
*
* This floating action button is using the Material Design concept of expandable
* Paper Fab Button and using the Polymer components to make the concept happen.
*
* *** EXAMPLE - without links ***
* <paper-fab-menu color="teal" icon="add" position="vertical">
* <paper-fab-menu-item color="teal" label="Favorites" icon="star" ></paper-fab-menu-item>
* <paper-fab-menu-item color="teal" label="Favorites" icon="star" ></paper-fab-menu-item>
* <paper-fab-menu-item color="teal" label="Favorites" icon="star" ></paper-fab-menu-item>
* </paper-fab-menu>
*
* *** EXAMPLE - with links ***
*
* <paper-fab-menu color="red" icon="add" position="horizontal">
* <a href="#/favorites">
* <paper-fab-menu-item color="red" label="Favorites" icon="star" ></paper-fab-menu-item>
* </a>
* <a href="#/favorites">
* <paper-fab-menu-item color="red" label="Favorites" icon="star" ></paper-fab-menu-item>
* </a>
* <a href="#/favorites">
* <paper-fab-menu-item color="red" label="Favorites" icon="star" ></paper-fab-menu-item>
* </a>
* </paper-fab-menu>
*
********** -->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-icons/iron-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-tooltip/paper-tooltip.html">
<link rel="import" href="../iron-flex-layout/classes/iron-flex-layout.html">
<link rel="import" href="paper-fab-menu-item.html">
<dom-module id="paper-fab-menu">
<style is="custom-style">
:host {
width : 60px;
}
:host .layout {
max-width:;
}
:host([position="vertical"]) .menu-fab-button {
padding-top : 7px;
}
:host([position="vertical reversed"]) .menu-fab-button {
padding-bottom : 7px;
}
:host([position="horizontal"]) .menu-fab-button {
padding-left : 7px;
}
:host([position="horizontal reversed"]) .menu-fab-button {
padding-right : 7px;
}
:host-context([dir="rtl"]) :host([position="horizontal"]) .menu-fab-button,
:host-context([dir="rtl"])[position="horizontal"] .menu-fab-button, /* Polymer workaround */
:host([dir="rtl"][position="horizontal"]) .menu-fab-button {
padding-left : 0;
padding-right : 7px;
}
:host-context([dir="rtl"]) :host([position="horizontal reversed"]) .menu-fab-button,
:host-context([dir="rtl"])[position="horizontal reversed"] .menu-fab-button, /* Polymer workaround */
:host([dir="rtl"][position="horizontal reversed"]) .menu-fab-button {
padding-right : 0;
padding-left : 7px;
}
:host .menu-items ::content a {
display: block;
margin: 7px;
}
:host .menu-items ::content a > paper-fab-menu-item {
margin: 0;
}
:host paper-fab ::content iron-icon {
transition : 200ms all;
}
:host .menu-fab-button[open] paper-fab ::content iron-icon {
transform : rotate(45deg);
}
:host .menu-items {
order : 1;
}
:host .menu-fab-button {
order : 2;
}
:host .menu-items[open] ::content .menu-item {
transform : scale(1);
}
:host .menu-items ::content paper-fab-menu-item:nth-child(1) .menu-item, :host .menu-items ::content a:nth-child(1) .menu-item {
transition-delay: 450ms;
}
:host .menu-items ::content paper-fab-menu-item:nth-child(2) .menu-item, :host .menu-items ::content a:nth-child(2) .menu-item {
transition-delay: 400ms;
}
:host .menu-items ::content paper-fab-menu-item:nth-child(3) .menu-item, :host .menu-items ::content a:nth-child(3) .menu-item {
transition-delay: 350ms;
}
:host .menu-items ::content paper-fab-menu-item:nth-child(4) .menu-item, :host .menu-items ::content a:nth-child(4) .menu-item {
transition-delay: 300ms;
}
:host .menu-items ::content paper-fab-menu-item:nth-child(5) .menu-item, :host .menu-items ::content a:nth-child(5) .menu-item {
transition-delay: 250ms;
}
:host .menu-items ::content paper-fab-menu-item:nth-child(6) .menu-item, :host .menu-items ::content a:nth-child(6) .menu-item {
transition-delay: 250ms;
}
:host .menu-items ::content paper-fab-menu-item .menu-item, :host .menu-items ::content a .menu-item
{
transition: 200ms all;
}
/*REVERSED-STYLE-START*/
:host .menu-items.reversed {
order : 3;
}
:host .menu-items.reversed ::content paper-fab-menu-item:nth-child(1) .menu-item, :host .menu-items.reversed ::content a:nth-child(1) .menu-item {
transition-delay: 200ms;
}
:host .menu-items.reversed ::content paper-fab-menu-item:nth-child(2) .menu-item, :host .menu-items.reversed ::content a:nth-child(2) .menu-item {
transition-delay: 250ms;
}
:host .menu-items.reversed ::content paper-fab-menu-item:nth-child(3) .menu-item, :host .menu-items.reversed ::content a:nth-child(3) .menu-item {
transition-delay: 300ms;
}
:host .menu-items.reversed ::content paper-fab-menu-item:nth-child(4) .menu-item, :host .menu-items.reversed ::content a:nth-child(4) .menu-item {
transition-delay: 350ms;
}
:host .menu-items.reversed ::content paper-fab-menu-item:nth-child(5) .menu-item, :host .menu-items.reversed ::content a:nth-child(5) .menu-item {
transition-delay: 400ms;
}
:host .menu-items.reversed ::content paper-fab-menu-item:nth-child(6) .menu-item, :host .menu-items.reversed ::content a:nth-child(6) .menu-item {
transition-delay: 450ms;
}
/*REVERSED-STYLE-END*/
:host paper-fab {
transform : scale(0);
animation : 600ms scale 600ms 1 forwards alternate cubic-bezier(0.165, 0.84, 0.44, 1);
}
@keyframes scale {
0% {
transform : scale(0);
-webkit-transform : scale(0);
}
100% {
transform : scale(1.0);
-webkit-transform : scale(1.0);
}
}
</style>
<template>
<div class$="layout {{position}}">
<div open$="{{ show }}" id="mainFab" class="menu-fab-button layout vertical self-center" on-tap='open'>
<paper-fab id="paperFab" icon="{{ icon }}"></paper-fab>
</div>
<template is='dom-if' if='{{show}}'>
<div open$="{{ show }}" id="mainItems" class$="menu-items flex layout {{position}} self-center">
<content select="a, paper-fab-menu-item"></content>
</div>
</template>
</div>
</template>
<script>
Polymer({
is : 'paper-fab-menu',
properties : {
position : {
value : 'vertical' // ALLOWED: 'vertical', 'horizontal', 'vertical reversed', 'horizontal reversed'
},
show : {
value : false
},
color: {
type: String // any color you would like to be a main paper-fab
}
},
listeners : {
'mainFab.ontap' : 'open'
},
ready: function () {
var that = this;
window.addEventListener('click', function (e) {
if (e.target.tagName !== 'PAPER-FAB' && e.target.tagName !== 'IRON-ICON') {
that.close();
}
});
if(this.color)
this.$.paperFab.style.backgroundColor = this.color;
},
open : function() {
if (this.show) {
this.show = false;
} else {
this.show = true;
}
},
close : function() {
this.show = false;
}
})
</script>
</dom-module>