Skip to content

Commit

Permalink
fix(menu): 对菜单做了一些调整和优化。 (halo-dev/console#267)
Browse files Browse the repository at this point in the history
* fix(menu): 对菜单做了一些调整和优化。

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

* pref: add animation for menu drag.

Co-authored-by: Ryan Wang <i@ryanc.cc>
  • Loading branch information
LIlGG and ruibaby authored Nov 24, 2020
1 parent 7abb68f commit 558c1e0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/components/global.less
Original file line number Diff line number Diff line change
Expand Up @@ -868,3 +868,10 @@ body {
left: 0;
}
}

.card-header-fixed .ant-card-head {
position: fixed;
background: white;
z-index: 999;
top: 0;
}
22 changes: 21 additions & 1 deletion src/views/interface/MenuList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@
:xs="24"
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">
<span>
{{ menuListTitle }}
Expand Down Expand Up @@ -220,6 +225,8 @@ export default {
menuInternalLinkSelector: {
visible: false,
},
headerIsFixed: false,
headStyle: {},
}
},
computed: {
Expand Down Expand Up @@ -260,10 +267,16 @@ export default {
defaultMenuTeam() {
return this.options.default_menu_team ? this.options.default_menu_team : ''
},
mHeaderFromTopAbs() {
return Math.floor(Math.abs(this.mHeaderFromTop))
},
},
created() {
this.handleListTeams()
},
mounted() {
window.addEventListener('scroll', this.scrollHandle, true)
},
methods: {
...mapActions(['refreshOptionsCache']),
handleListTeams(autoSelectTeam = false) {
Expand Down Expand Up @@ -403,6 +416,13 @@ export default {
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>
4 changes: 3 additions & 1 deletion src/views/interface/components/MenuTreeNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@ export default {
computed: {
dragOptions() {
return {
animation: 300,
animation: 100,
group: 'description',
disabled: false,
ghostClass: 'ghost',
forceFallback: true,
emptyInsertThreshold: 20,
}
},
realValue() {
Expand Down

0 comments on commit 558c1e0

Please sign in to comment.