Skip to content

Commit 9805681

Browse files
committed
More fixes and visual improvements
1 parent 9e81a1d commit 9805681

File tree

2 files changed

+46
-19
lines changed

2 files changed

+46
-19
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-fab",
3-
"version": "1.0.8",
3+
"version": "1.0.9",
44
"description": "Vue Floating Action Button",
55
"main": "src/index.js",
66
"scripts": {

src/FAB.vue

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
<template>
22
<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>
1416
<div @click="toggle = !toggle"
15-
class="fab pointer" v-bind:style="{ 'background-color': styles.bgColor }"
17+
class="fab pointer" :style="{ 'background-color': styles.bgColor }"
1618
>
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>
1820
</div>
1921
</div>
2022
</template>
@@ -32,6 +34,20 @@
3234
},
3335
props: ['styles', 'actions'],
3436
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+
},
3551
transitionEnter() {
3652
let animation = this.animation;
3753
return animation.enter;
@@ -68,7 +84,7 @@
6884
this.toggle = false;
6985
},
7086
position() {
71-
this.pos = {}
87+
this.pos = {};
7288
switch (this.styles.position) {
7389
case 'bottom-right':
7490
this.pos.right = '5vw';
@@ -94,7 +110,7 @@
94110
moveTransition() {
95111
if (this.styles.position === 'top-right' || this.styles.position === 'top-left') {
96112
let wrapper = document.getElementsByClassName('fab-wrapper');
97-
let el = document.getElementsByClassName('fab-list');
113+
let el = document.getElementsByClassName('actions-container');
98114
wrapper[0].appendChild(el[0]);
99115
}
100116
}
@@ -116,13 +132,14 @@
116132
117133
.fab {
118134
border-radius: 100px;
119-
width: 68px;
135+
width: 65px;
120136
position: relative;
121137
overflow: hidden;
122-
height: 68px;
138+
height: 65px;
123139
display: flex;
124140
align-items: center;
125141
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
142+
z-index: 2;
126143
}
127144
128145
.fab .material-icons {
@@ -141,7 +158,7 @@
141158
142159
.fab-list {
143160
position: relative;
144-
z-index: 9999;
161+
z-index: 1;
145162
margin: 2vh 0.5vw;
146163
}
147164
@@ -164,6 +181,16 @@
164181
cursor: pointer;
165182
}
166183
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+
167194
/* Rules for sizing the icon. */
168195
.material-icons.md-18 { font-size: 18px; }
169196
.material-icons.md-24 { font-size: 24px; }

0 commit comments

Comments
 (0)