Skip to content

Commit 9bdfd44

Browse files
authored
Merge pull request #26 from jvb93/master
Added toggleable rotation, updated documentation
2 parents 14fd3c7 + 686c20f commit 9bdfd44

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ And
4545
| `main-tooltip` | String | <b>Default `null`</b> |
4646
| `actions` | Array | <b>[Details bellow](https://github.com/PygmySlowLoris/vue-fab/#actions)</b>
4747
| `fixed-tooltip` | Boolean | <b>Default 'false'</b><br> if true, it shows the tooltip beside the actions
48+
| `enable-rotation` | Boolean | <b>Default 'true'</b><br> if true, the fab will rotate to indicate that it has been opened. Will not rotate if there are no actions specified.
4849

4950
### actions
5051

demo/App.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@
160160
</div>
161161
</div>
162162
</div>
163+
<label class="checkbox" style="display: flex; align-items: center; padding-right: 1rem;">
164+
<input type="checkbox" v-model="enableRotation">
165+
Enable Rotation
166+
</label>
163167
</div>
164168
</div>
165169
<div class="columns">
@@ -198,6 +202,7 @@
198202
:actions="[{name: 'alertMe',icon: firstIcon, tooltip: firstTooltip, color:'#d11014'},{name: 'alertMe',icon: secondIcon, tooltip: secondTooltip}]"
199203
@alertMe="alert"
200204
:fixed-tooltip="fixedTooltip"
205+
:enable-rotation="enableRotation"
201206
></fab>
202207
</div>
203208
</template>
@@ -271,7 +276,8 @@
271276
firstIcon: 'cached',
272277
firstTooltip: 'cached',
273278
secondIcon: 'add_alert',
274-
secondTooltip: 'add_alert'
279+
secondTooltip: 'add_alert',
280+
enableRotation: true
275281
}
276282
},
277283
computed: {

src/FAB.vue

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@
3737
v-tooltip="{ content: mainTooltip, placement: tooltipPosition, classes: 'fab-tooltip' }"
3838
class="fab-main pointer" :style="{ 'background-color': bgColor, 'padding': paddingAmount }"
3939
>
40-
<i :class="[ mainIconSize , { rotate: toggle } ,'material-icons main']">{{mainIcon}}</i>
41-
<i :class="[ mainIconSize , { rotate: toggle } ,'material-icons close']">add</i>
40+
<i :class="[ mainIconSize , { rotate: toggle && allowRotation } ,'material-icons main']">{{mainIcon}}</i>
41+
<i :class="[ mainIconSize , { rotate: toggle && allowRotation } ,'material-icons close']">add</i>
4242
</div>
4343
</template>
4444
<template v-else>
4545
<div v-ripple="rippleColor == 'light' ? 'rgba(255, 255, 255, 0.35)' : ''" @click="toggle = !toggle"
4646
class="fab-main pointer" :style="{ 'background-color': bgColor, 'padding': paddingAmount }"
4747
>
48-
<i :class="[ mainIconSize , { rotate: toggle }, 'material-icons main']">{{mainIcon}}</i>
49-
<i :class="[ mainIconSize , { rotate: toggle }, 'material-icons close']">add</i>
48+
<i :class="[ mainIconSize , { rotate: toggle && allowRotation }, 'material-icons main']">{{mainIcon}}</i>
49+
<i :class="[ mainIconSize , { rotate: toggle && allowRotation }, 'material-icons close']">add</i>
5050
</div>
5151
</template>
5252
</template>
@@ -55,15 +55,15 @@
5555
<div v-bind:v-tooltip="{ content: mainTooltip, placement: tooltipPosition, classes: 'fab-tooltip'}"
5656
class="fab-main pointer" :style="{ 'background-color': bgColor, 'padding': paddingAmount }"
5757
>
58-
<i class="material-icons md-36 main" :class="{ rotate: toggle }">{{mainIcon}}</i>
59-
<i class="material-icons md-36 close" :class="{ rotate: toggle }">add</i>
58+
<i class="material-icons md-36 main" :class="{ rotate: toggle && allowRotation }">{{mainIcon}}</i>
59+
<i class="material-icons md-36 close" :class="{ rotate: toggle && allowRotation }">add</i>
6060
</div>
6161
</template>
6262
<template v-else>
6363
<div class="fab-main pointer" :style="{ 'background-color': bgColor, 'padding': paddingAmount }"
6464
>
65-
<i class="material-icons md-36 main" :class="{ rotate: toggle }">{{mainIcon}}</i>
66-
<i class="material-icons md-36 close" :class="{ rotate: toggle }">add</i>
65+
<i class="material-icons md-36 main" :class="{ rotate: toggle && allowRotation }">{{mainIcon}}</i>
66+
<i class="material-icons md-36 close" :class="{ rotate: toggle && allowRotation }">add</i>
6767
</div>
6868
</template>
6969
</template>
@@ -116,9 +116,12 @@
116116
fixedTooltip: {
117117
default: false
118118
},
119+
enableRotation:{
120+
default: true
121+
},
119122
actions: {
120123
default: () => []
121-
}
124+
}
122125
},
123126
computed: {
124127
actionIconSize() {
@@ -136,6 +139,9 @@
136139
return 'md-24';
137140
}
138141
},
142+
allowRotation(){
143+
return this.enableRotation && this.actions && this.actions.length;
144+
},
139145
mainIconSize() {
140146
switch (this.iconSize) {
141147
case 'small':

0 commit comments

Comments
 (0)