Skip to content

Commit 3d5494c

Browse files
committed
[Feature] Now you can set the tooltip as fixed.
When the actions are shown their tooltips will be shown as well.
1 parent 1573036 commit 3d5494c

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

src/FAB.vue

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
leave-active-class="animated quick zoomOut"
1414
>
1515
<template v-if="action.tooltip">
16-
<li v-if="toggle" :style="{ 'background-color': action.color || bgColor }"
17-
v-tooltip="{ content: action.tooltip, placement: tooltipPosition, classes: 'fab-tooltip' }"
18-
@click="toParent(action.name)" class="pointer">
16+
<li v-show="toggle" :style="{ 'background-color': action.color || bgColor }"
17+
v-tooltip="{ content: action.tooltip, placement: tooltipPosition, classes: 'fab-tooltip', trigger: tooltipTrigger}"
18+
@click="toParent(action.name)" class="pointer"
19+
ref="actions">
1920
<i :class="[ actionIconSize ,'material-icons']">{{action.icon}}</i>
2021
</li>
2122
</template>
@@ -72,7 +73,7 @@
7273
<script>
7374
import {mixin as clickaway} from 'vue-clickaway';
7475
import Ripple from 'vue-ripple-directive';
75-
import { VTooltip } from 'v-tooltip'
76+
import {VTooltip} from 'v-tooltip'
7677
7778
export default {
7879
mixins: [clickaway],
@@ -112,6 +113,9 @@
112113
mainTooltip: {
113114
default: null
114115
},
116+
fixedTooltip: {
117+
default: false
118+
},
115119
actions: {}
116120
},
117121
computed: {
@@ -197,13 +201,21 @@
197201
leave: 'animated fadeOutDown'
198202
};
199203
}
204+
},
205+
tooltipTrigger() {
206+
207+
if (this.fixedTooltip) {
208+
return 'manual';
209+
}
210+
211+
return 'hover';
200212
}
201213
},
202214
methods: {
203215
tooltipPos() {
204-
if(this.position === 'top-right' || this.position === 'bottom-right') {
216+
if (this.position === 'top-right' || this.position === 'bottom-right') {
205217
this.tooltipPosition = 'left'
206-
} else {
218+
} else {
207219
this.tooltipPosition = 'right'
208220
}
209221
},
@@ -247,6 +259,22 @@
247259
} else {
248260
wrapper.insertBefore(el, wrapper.childNodes[0]);
249261
}
262+
},
263+
showTooltip(show) {
264+
if (show && this.$refs.actions && this.fixedTooltip) {
265+
266+
//timeout to prevent wrong position for the tooltip
267+
setTimeout(() => {
268+
this.$refs.actions.forEach((item) => {
269+
item._tooltip.show();
270+
});
271+
},600);
272+
273+
}else{
274+
this.$refs.actions.forEach((item) => {
275+
item._tooltip.hide();
276+
});
277+
}
250278
}
251279
},
252280
watch: {
@@ -257,6 +285,9 @@
257285
this.moveTransition();
258286
this.tooltipPos();
259287
});
288+
},
289+
toggle(val) {
290+
this.showTooltip(val);
260291
}
261292
},
262293
mounted() {
@@ -282,7 +313,7 @@
282313
padding: 5px 10px 4px;
283314
}
284315
285-
.fab-tooltip.tooltip tooltip-arrow{
316+
.fab-tooltip.tooltip tooltip-arrow {
286317
display: none;
287318
}
288319

0 commit comments

Comments
 (0)