fix(menu): 对菜单做了一些调整和优化。 (halo-dev/console#267)

* fix(menu): 对菜单做了一些调整和优化。

1. 删除了菜单的动画效果
2. 当拖拽到菜单底部时,会触发滚动效果
3. 现在拖为子节点会方便那么一点(也不是很完美)
4. 当菜单头不在可视区域时,会触发跟随,不需要拖拽完菜单还需要返回顶部再保存了。

* pref: add animation for menu drag.

Co-authored-by: Ryan Wang <i@ryanc.cc>
pull/3445/head
Li 2020-11-24 11:10:50 +08:00 committed by GitHub
parent 7abb68f60f
commit 558c1e03fc
3 changed files with 31 additions and 2 deletions

View File

@ -868,3 +868,10 @@ body {
left: 0; left: 0;
} }
} }
.card-header-fixed .ant-card-head {
position: fixed;
background: white;
z-index: 999;
top: 0;
}

View File

@ -93,7 +93,12 @@
:xs="24" :xs="24"
class="pb-3" class="pb-3"
> >
<a-card :bodyStyle="{ padding: '16px' }"> <a-card
:bodyStyle="{ padding: '16px' }"
ref="mheader"
:class="{ 'card-header-fixed': headerIsFixed }"
:headStyle="headStyle"
>
<template slot="title"> <template slot="title">
<span> <span>
{{ menuListTitle }} {{ menuListTitle }}
@ -220,6 +225,8 @@ export default {
menuInternalLinkSelector: { menuInternalLinkSelector: {
visible: false, visible: false,
}, },
headerIsFixed: false,
headStyle: {},
} }
}, },
computed: { computed: {
@ -260,10 +267,16 @@ export default {
defaultMenuTeam() { defaultMenuTeam() {
return this.options.default_menu_team ? this.options.default_menu_team : '' return this.options.default_menu_team ? this.options.default_menu_team : ''
}, },
mHeaderFromTopAbs() {
return Math.floor(Math.abs(this.mHeaderFromTop))
},
}, },
created() { created() {
this.handleListTeams() this.handleListTeams()
}, },
mounted() {
window.addEventListener('scroll', this.scrollHandle, true)
},
methods: { methods: {
...mapActions(['refreshOptionsCache']), ...mapActions(['refreshOptionsCache']),
handleListTeams(autoSelectTeam = false) { handleListTeams(autoSelectTeam = false) {
@ -403,6 +416,13 @@ export default {
this.refreshOptionsCache() this.refreshOptionsCache()
} }
}, },
scrollHandle: function(e) {
if (this.$refs.mheader.$el !== undefined) {
this.headerIsFixed = this.$refs.mheader.$el.getBoundingClientRect().top < 0
this.$set(this.headStyle, 'width', this.$refs.mheader.$el.offsetWidth + 'px')
}
},
}, },
} }
</script> </script>

View File

@ -146,10 +146,12 @@ export default {
computed: { computed: {
dragOptions() { dragOptions() {
return { return {
animation: 300, animation: 100,
group: 'description', group: 'description',
disabled: false, disabled: false,
ghostClass: 'ghost', ghostClass: 'ghost',
forceFallback: true,
emptyInsertThreshold: 20,
} }
}, },
realValue() { realValue() {