-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcube-dropdown.html
121 lines (112 loc) · 3.54 KB
/
cube-dropdown.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
<link rel="import" href="../iron-dropdown/iron-dropdown.html">
<link rel="import" href="../neon-animation/web-animations.html">
<link rel="import" href="../neon-animation/animations/fade-in-animation.html">
<link rel="import" href="../neon-animation/animations/fade-out-animation.html">
<link rel="import" href="../neon-animation/animations/slide-down-animation.html">
<link rel="import" href="../paper-styles/shadow.html">
<link rel="import" href="cube-dropdown-expand-animation.html">
<dom-module id="cube-dropdown"
attributes="vertical-align horizontal-align disabled open-animation-config close-animation-config">
<template>
<style>
:host iron-dropdown {
@apply --shadow-elevation-2dp;
@apply --cube-dropdown-style;
}
.triggerContainer {
line-height: normal;
}
</style>
<div class="triggerContainer" on-tap="toggle">
<slot name="trigger"></slot>
</div>
<iron-dropdown id="dropdown"
no-overlap
vertical-align="[[verticalAlign]]"
horizontal-align="[[horizontalAlign]]"
disabled="[[disabled]]"
open-animation-config="[[openAnimationConfig]]"
close-animation-config="[[closeAnimationConfig]]">
<slot slot="dropdown-content"></slot>
</iron-dropdown>
</template>
<script>
Polymer(
{
is: 'cube-dropdown',
properties: {
verticalAlign: {
type: String,
value: 'top'
},
horizontalAlign: {
type: String,
value: 'auto'
},
disabled: Boolean,
openAnimationConfig: {
type: Array,
value: function ()
{
return [
{
name: 'fade-in-animation',
timing: {
delay: 150,
duration: 50
}
}, {
name: 'cube-dropdown-expand-animation',
timing: {
delay: 150,
duration: 200
}
}
];
}
},
closeAnimationConfig: {
type: Array,
value: function ()
{
return [
{
name: 'fade-out-animation',
timing: {
duration: 200
}
}
];
}
}
},
attached: function ()
{
this.addEventListener('iron-overlay-canceled', function (e)
{
if(e.detail.path.indexOf(this) > -1)
{
e.preventDefault();
}
}.bind(this));
},
refit: function ()
{
this.$.dropdown.refit();
},
open: function ()
{
this.$.dropdown.open();
},
close: function ()
{
this.$.dropdown.close();
},
toggle: function ()
{
this.$.dropdown.toggle();
}
}
);
</script>
</dom-module>