|
1 | 1 | <template> |
2 | 2 | <div class="fab-wrapper" v-on-clickaway="away" :style="[pos, {zIndex: styles.zIndex}]" > |
3 | | - <transition name="fab-actions-appear" |
4 | | - :enter-active-class="transitionEnter" |
5 | | - :leave-active-class="transitionLeave" |
6 | | - > |
7 | | - <ul v-show="toggle" class="fab-list"> |
8 | | - <li v-for="action in actions" v-bind:style="{ 'background-color': styles.bgColor }" |
9 | | - v-on:click="toParent(action.name)" class="pointer"> |
10 | | - <i class="material-icons">{{action.icon}}</i> |
11 | | - </li> |
12 | | - </ul> |
13 | | - </transition> |
| 3 | + <div class="actions-container" :style="listPos"> |
| 4 | + <transition name="fab-actions-appear" |
| 5 | + :enter-active-class="transitionEnter" |
| 6 | + :leave-active-class="transitionLeave" |
| 7 | + > |
| 8 | + <ul v-show="toggle" class="fab-list"> |
| 9 | + <li v-for="action in actions" :style="{ 'background-color': styles.bgColor }" |
| 10 | + @click="toParent(action.name)" class="pointer"> |
| 11 | + <i class="material-icons">{{action.icon}}</i> |
| 12 | + </li> |
| 13 | + </ul> |
| 14 | + </transition> |
| 15 | + </div> |
14 | 16 | <div @click="toggle = !toggle" |
15 | | - class="fab pointer" v-bind:style="{ 'background-color': styles.bgColor }" |
| 17 | + class="fab pointer" :style="{ 'background-color': styles.bgColor }" |
16 | 18 | > |
17 | | - <i class="material-icons md-36" v-bind:class="{ rotate: toggle }">add</i> |
| 19 | + <i class="material-icons md-36" :class="{ rotate: toggle }">add</i> |
18 | 20 | </div> |
19 | 21 | </div> |
20 | 22 | </template> |
|
32 | 34 | }, |
33 | 35 | props: ['styles', 'actions'], |
34 | 36 | computed: { |
| 37 | + listPos() { |
| 38 | + let mask = {}; |
| 39 | + if (this.styles.position === 'top-right' || this.styles.position === 'top-left') { |
| 40 | + return mask = { |
| 41 | + top: '-20px', |
| 42 | + paddingTop: '20px' |
| 43 | + } |
| 44 | + } else { |
| 45 | + return mask = { |
| 46 | + bottom: '-20px', |
| 47 | + paddingBottom: '20px' |
| 48 | + } |
| 49 | + } |
| 50 | + }, |
35 | 51 | transitionEnter() { |
36 | 52 | let animation = this.animation; |
37 | 53 | return animation.enter; |
|
68 | 84 | this.toggle = false; |
69 | 85 | }, |
70 | 86 | position() { |
71 | | - this.pos = {} |
| 87 | + this.pos = {}; |
72 | 88 | switch (this.styles.position) { |
73 | 89 | case 'bottom-right': |
74 | 90 | this.pos.right = '5vw'; |
|
94 | 110 | moveTransition() { |
95 | 111 | if (this.styles.position === 'top-right' || this.styles.position === 'top-left') { |
96 | 112 | let wrapper = document.getElementsByClassName('fab-wrapper'); |
97 | | - let el = document.getElementsByClassName('fab-list'); |
| 113 | + let el = document.getElementsByClassName('actions-container'); |
98 | 114 | wrapper[0].appendChild(el[0]); |
99 | 115 | } |
100 | 116 | } |
|
116 | 132 |
|
117 | 133 | .fab { |
118 | 134 | border-radius: 100px; |
119 | | - width: 68px; |
| 135 | + width: 65px; |
120 | 136 | position: relative; |
121 | 137 | overflow: hidden; |
122 | | - height: 68px; |
| 138 | + height: 65px; |
123 | 139 | display: flex; |
124 | 140 | align-items: center; |
125 | 141 | box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23); |
| 142 | + z-index: 2; |
126 | 143 | } |
127 | 144 |
|
128 | 145 | .fab .material-icons { |
|
141 | 158 |
|
142 | 159 | .fab-list { |
143 | 160 | position: relative; |
144 | | - z-index: 9999; |
| 161 | + z-index: 1; |
145 | 162 | margin: 2vh 0.5vw; |
146 | 163 | } |
147 | 164 |
|
|
164 | 181 | cursor: pointer; |
165 | 182 | } |
166 | 183 |
|
| 184 | + .fab ul { |
| 185 | + padding: 0; |
| 186 | + } |
| 187 | +
|
| 188 | + .fab-wrapper .actions-container { |
| 189 | + overflow: hidden; |
| 190 | + z-index: 0; |
| 191 | + position: relative; |
| 192 | + } |
| 193 | +
|
167 | 194 | /* Rules for sizing the icon. */ |
168 | 195 | .material-icons.md-18 { font-size: 18px; } |
169 | 196 | .material-icons.md-24 { font-size: 24px; } |
|
0 commit comments