调整悬浮按钮交互方式

This commit is contained in:
2021-06-15 00:46:37 +08:00
parent 13769aa057
commit b55f5c3d6a

View File

@@ -1,6 +1,6 @@
<template> <template>
<div class="floating-btn"> <div ref="floatingBtn" class="floating-btn">
<div class="btns-inner"> <div :class="['btns-inner', { show: showInner }]">
<button class="btn" type="button" title="折叠侧边菜单" @click="toggleSideCollapse()"> <button class="btn" type="button" title="折叠侧边菜单" @click="toggleSideCollapse()">
<i class="el-icon-menu" aria-hidden="true"></i> <i class="el-icon-menu" aria-hidden="true"></i>
</button> </button>
@@ -24,7 +24,8 @@ export default {
name: 'FloatingBtn', name: 'FloatingBtn',
data() { data() {
return { return {
config: this.$root.config.storage config: this.$root.config.storage,
showInner: false
} }
}, },
mounted () { mounted () {
@@ -36,19 +37,29 @@ export default {
* 设置动画 * 设置动画
*/ */
initAnimation() { initAnimation() {
var btns = document.querySelectorAll('.floating-btn .btn'); var vm = this;
var el = vm.$refs['floatingBtn'];
var btns = el.querySelectorAll('.btn');
var className = 'animate'; var className = 'animate';
btns.forEach((elem) => { btns.forEach((elem) => {
elem.onclick = function () { elem.addEventListener('click', function () {
this.classList.remove(className); this.classList.remove(className);
setTimeout(() => { setTimeout(() => {
this.classList.add(className); this.classList.add(className);
vm.toggleInnerBtns();
}, 20); }, 20);
}; });
}); });
}, },
/**
* 切换按钮显示
*/
toggleInnerBtns() {
this.showInner = !this.showInner;
},
/** /**
* 返回主页 * 返回主页
*/ */
@@ -82,7 +93,6 @@ export default {
*/ */
toggleSideCollapse() { toggleSideCollapse() {
var cfg = this.config; var cfg = this.config;
cfg.sideMenuCollapse = !cfg.sideMenuCollapse; cfg.sideMenuCollapse = !cfg.sideMenuCollapse;
}, },
@@ -98,13 +108,11 @@ export default {
bottom: 2rem; bottom: 2rem;
text-align: center; text-align: center;
&:hover { .btns-inner.show .btn {
.btns-inner .btn { width: 2.6rem;
width: 2.6rem; height: 2.6rem;
height: 2.6rem; font-size: 1rem;
font-size: 1rem; color: #FFF;
color: #FFF;
}
} }
} }
@@ -117,7 +125,7 @@ export default {
background-color: @colorSecondary; background-color: @colorSecondary;
font-size: 0; font-size: 0;
color: transparent; color: transparent;
transition: all calc(@transitionTime * 1.6); transition: all @transitionTime;
&:not(:first-child) { &:not(:first-child) {
margin-top: 0.75rem; margin-top: 0.75rem;