Skip to content

Commit 9993f99

Browse files
committed
New animations & possibility to modify main icon
- zoomIn animation when actions appear - Main Icon can be modified now (after rotating the X will appear).
1 parent b770dfa commit 9993f99

File tree

5 files changed

+78
-21
lines changed

5 files changed

+78
-21
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ And
3939
| `z-index` | String | <b>Default '999'</b> <br>Set any value that suits your needs. |
4040
| `ripple-show` | Boolean | <b>Default true</b> <br>Options: true or false. |
4141
| `ripple-color` | String | <b>Default 'light'</b> <br>Options: 'light' or 'dark'. |
42+
| `main-icon` | String | <b>Default 'add'</b> <br>Use icons from the material icon library. |
4243
| `actions` | Object | Has <b>two properties</b>: <br> -`name` (String) Name of the event. <br> -`icon`(String) Icon name. (Please refer to [Material icons](https://material.io/icons/))|
4344

4445

demo/App.vue

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
<hr class="is-marginless">
2626
<h2 class="subtitle text-light-grey" style="margin-top: .5rem">
2727
A Vue Component
28+
<span class="is-pulled-right">
29+
<!-- Place this tag where you want the button to render. -->
30+
<a class="github-button" href="https://github.com/PygmySlowLoris/vue-fab" data-icon="octicon-star" data-size="large" aria-label="Star PygmySlowLoris/vue-fab on GitHub">Star</a>
31+
</span>
2832
</h2>
2933
</div>
3034
</div>
@@ -48,7 +52,7 @@
4852
</div>
4953
<div class="content">
5054
<div class="columns">
51-
<div class="column">
55+
<div class="column is-5" style="display: flex; justify-content: center">
5256
<div class="field is-pulled-left">
5357
<label class="label">Color</label>
5458
<p class="control">
@@ -57,20 +61,29 @@
5761
</div>
5862
</div>
5963
<div class="column">
64+
<div class="field has-text-left">
65+
<label class="label">Position</label>
66+
<p class="control">
67+
<span class="select">
68+
<select v-model="position">
69+
<option v-for="pos in positions">{{pos}}</option>
70+
</select>
71+
</span>
72+
</p>
73+
</div>
6074
<div class="field">
61-
<label class="label is-pulled-left">Position</label>
62-
<br/>
75+
<label class="label is-pulled-left">Main Icon</label>
6376
<p class="control">
64-
<span class="select">
65-
<select v-model="position">
66-
<option v-for="pos in positions">{{pos}}</option>
67-
</select>
68-
</span>
77+
<input type="text" class="input" v-model="mainIcon">
6978
</p>
79+
</div>
80+
<div class="field">
7081
<label class="label is-pulled-left">First Icon</label>
7182
<p class="control">
7283
<input type="text" class="input" v-model="firstIcon">
7384
</p>
85+
</div>
86+
<div class="field">
7487
<label class="label is-pulled-left">Second Icon</label>
7588
<p class="control">
7689
<input type="text" class="input" v-model="secondIcon">
@@ -107,6 +120,7 @@
107120
<fab
108121
:position="position"
109122
:bg-color="colors.hex"
123+
:main-icon="mainIcon"
110124
:actions="[{name: 'alertMe',icon: firstIcon},{name: 'alertMe',icon: secondIcon}]"
111125
@alertMe="alert"
112126
></fab>
@@ -161,9 +175,9 @@
161175
],
162176
position: 'bottom-right',
163177
colors: defaultProps,
178+
mainIcon: 'add',
164179
firstIcon: 'cached',
165180
secondIcon: 'add_alert'
166-
167181
}
168182
},
169183
methods: {

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
<body>
1010
<div id="app"></div>
1111
<script src="./dist/build.js"></script>
12+
<script async defer src="https://buttons.github.io/buttons.js"></script>
1213
</body>
1314
</html>

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": "2.0.2",
3+
"version": "2.0.3",
44
"description": "Vue Floating Action Button",
55
"main": "src/index.js",
66
"repository": {

src/FAB.vue

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,34 @@
77
:leave-active-class="transitionLeave"
88
>
99
<ul v-show="toggle" class="fab-list">
10-
<li v-for="action in actions" :style="{ 'background-color': bgColor }"
11-
@click="toParent(action.name)" class="pointer">
12-
<i class="material-icons">{{action.icon}}</i>
13-
</li>
10+
<template v-for="action in actions">
11+
<transition
12+
enter-active-class="animated quick zoomIn"
13+
leave-active-class="animated quick zoomOut"
14+
>
15+
<li v-if="toggle" :style="{ 'background-color': bgColor }"
16+
@click="toParent(action.name)" class="pointer">
17+
<i class="material-icons">{{action.icon}}</i>
18+
</li>
19+
</transition>
20+
</template>
1421
</ul>
1522
</transition>
1623
</div>
1724
<template v-if="rippleShow">
1825
<div v-ripple="rippleColor == 'light' ? 'rgba(255, 255, 255, 0.35)' : ''" @click="toggle = !toggle"
1926
class="fab pointer" :style="{ 'background-color': bgColor }"
2027
>
21-
<i class="material-icons md-36" :class="{ rotate: toggle }">add</i>
28+
<i class="material-icons md-36 main" :class="{ rotate: toggle }">{{mainIcon}}</i>
29+
<i class="material-icons md-36 close" :class="{ rotate: toggle }">add</i>
2230
</div>
2331
</template>
2432
<template v-else>
2533
<div @click="toggle = !toggle"
2634
class="fab pointer" :style="{ 'background-color': bgColor, 'z-index': zIndex }"
2735
>
28-
<i class="material-icons md-36" :class="{ rotate: toggle }">add</i>
36+
<i class="material-icons md-36 main" :class="{ rotate: toggle }">{{mainIcon}}</i>
37+
<i class="material-icons md-36 close" :class="{ rotate: toggle }">add</i>
2938
</div>
3039
</template>
3140
</div>
@@ -60,6 +69,9 @@
6069
rippleColor: {
6170
default: 'light'
6271
},
72+
mainIcon: {
73+
default: 'add'
74+
},
6375
actions: {}
6476
},
6577
computed: {
@@ -87,13 +99,13 @@
8799
animation() {
88100
if (this.position === 'top-right' || this.position === 'top-left') {
89101
return {
90-
enter: 'animated fadeInDown',
91-
leave: 'animated fadeOutUp'
102+
enter: 'animated quick fadeInDown',
103+
leave: 'animated quick fadeOutUp'
92104
};
93105
} else if (this.position === 'bottom-right' || this.position === 'bottom-left') {
94106
return {
95-
enter: 'animated fadeInUp',
96-
leave: 'animated fadeOutDown'
107+
enter: 'animated quick fadeInUp',
108+
leave: 'animated quick fadeOutDown'
97109
};
98110
} else {
99111
return {
@@ -165,6 +177,11 @@
165177
</script>
166178

167179
<style scoped>
180+
.animated.quick {
181+
-webkit-animation-duration: .7s !important;
182+
animation-duration: .7s !important;
183+
}
184+
168185
.fab-wrapper {
169186
position: fixed;
170187
z-index: 999;
@@ -190,10 +207,34 @@
190207
margin: 0px auto;
191208
}
192209
193-
.fab .material-icons.rotate {
210+
.fab .material-icons.main {
211+
opacity: 1;
212+
position: absolute;
213+
left: .9rem;
214+
}
215+
216+
.fab .material-icons.close {
217+
opacity: 0;
218+
position: absolute;
219+
left: .9rem;
220+
}
221+
222+
.fab .material-icons.main.rotate {
223+
-ms-transform: rotate(315deg); /* IE 9 */
224+
-webkit-transform: rotate(315deg); /* Chrome, Safari, Opera */
225+
transform: rotate(315deg);
226+
opacity: 0;
227+
-webkit-transition: opacity .3s ease-in, -webkit-transform .4s; /* Safari */
228+
transition: opacity .3s ease-in, transform .4s;
229+
}
230+
231+
.fab .material-icons.close.rotate {
194232
-ms-transform: rotate(315deg); /* IE 9 */
195233
-webkit-transform: rotate(315deg); /* Chrome, Safari, Opera */
196234
transform: rotate(315deg);
235+
opacity: 1;
236+
-webkit-transition: opacity .3s ease-in, -webkit-transform .4s; /* Safari */
237+
transition: opacity .3s ease-in, transform .4s;
197238
}
198239
199240
.fab-list {

0 commit comments

Comments
 (0)