refactor(menu): remove delayed-padding-left

This commit is contained in:
07akioni 2021-01-12 14:56:59 +08:00
parent 82dc4312b3
commit 7c1c3c66e5
5 changed files with 10 additions and 28 deletions

View File

@ -15,7 +15,7 @@
>
<template #trigger>
<n-menu-item-content
:padding-left="delayedPaddingLeft"
:padding-left="paddingLeft"
:max-icon-size="maxIconSize"
:active-icon-size="activeIconSize"
:title="title"

View File

@ -29,7 +29,7 @@ export default defineComponent({
'span',
{
class: 'n-menu-item-group-title',
style: `padding-left: ${this.delayedPaddingLeft}px;`
style: `padding-left: ${this.paddingLeft}px;`
},
[
h(render, {

View File

@ -1,4 +1,4 @@
import { h, withDirectives, vShow, ref, defineComponent } from 'vue'
import { h, ref, defineComponent } from 'vue'
import { NFadeInExpandTransition } from '../../_base'
import { NDropdown } from '../../dropdown'
import NMenuItemContent from './MenuItemContent.vue'
@ -89,7 +89,7 @@ export default defineComponent({
render () {
const createSubmenuItem = () => {
const {
delayedPaddingLeft,
paddingLeft,
collapsed,
mergedDisabled,
maxIconSize,
@ -103,7 +103,7 @@ export default defineComponent({
dropdownShow
} = this
return h(NMenuItemContent, {
paddingLeft: delayedPaddingLeft,
paddingLeft,
collapsed,
disabled: mergedDisabled,
maxIconSize,
@ -121,16 +121,15 @@ export default defineComponent({
return h(NFadeInExpandTransition, null, {
default: () => {
const { tmNodes, collapsed } = this
return withDirectives(
h(
return !collapsed
? h(
'div',
{
class: 'n-submenu-children'
},
tmNodes.map((item) => itemRenderer(item))
),
[[vShow, !collapsed]]
)
)
: null
}
})
}

View File

@ -1,5 +1,3 @@
import { nextTick } from 'vue'
export default {
inject: {
NMenu: {
@ -30,21 +28,6 @@ export default {
default: undefined
}
},
data () {
return {
delayedPaddingLeft: undefined
}
},
created () {
this.delayedPaddingLeft = this.paddingLeft
},
watch: {
paddingLeft (value) {
nextTick(() => {
this.delayedPaddingLeft = value
})
}
},
computed: {
horizontal () {
return this.NMenu.mode === 'horizontal'

View File

@ -257,7 +257,7 @@ export default cB('menu', {
padding: 0
}, [
fadeInHeightExpandTransition({
duration: '.2s'
duration: '.3s'
})
])
]),