fix(dialog): enter animation not right

This commit is contained in:
07akioni 2020-11-15 00:25:42 +08:00
parent 10aa0dd029
commit 4988961822
3 changed files with 31 additions and 2 deletions

View File

@ -2,6 +2,8 @@
<n-modal
v-model:show="show"
appear
:clicked="clicked"
:click-position="clickPosition"
:to="to"
:mask-closable="maskClosable"
@after-leave="handleAfterHide"
@ -59,6 +61,14 @@ export default {
onInternalAfterLeave: {
type: Function,
required: true
},
clicked: {
type: Boolean,
default: undefined
},
clickPosition: {
type: Object,
default: undefined
}
},
data () {

View File

@ -1,6 +1,7 @@
import { Fragment, ref, h, reactive } from 'vue'
import { createId, omit } from '../../_utils/vue'
import DialogEnvironment from './DialogEnvironment.vue'
import { useClicked, useClickPosition } from 'vooks'
export default {
name: 'DialogProvider',
@ -23,7 +24,9 @@ export default {
setup () {
const dialogListRef = ref([])
return {
dialogList: dialogListRef
dialogList: dialogListRef,
clicked: useClicked(),
clickPosition: useClickPosition()
}
},
methods: {
@ -64,6 +67,8 @@ export default {
dialog,
['destroy'],
{
clicked: this.clicked,
clickPosition: this.clickPosition,
to: dialog.to ?? this.to,
ref: `n-dialog-${dialog.key}`,
onInternalAfterLeave: this.handleAfterLeave

View File

@ -76,6 +76,14 @@ export default {
type: Boolean,
default: undefined
},
clicked: {
type: Boolean,
default: undefined
},
clickPosition: {
type: Object,
default: null
},
// deprecated
onBeforeHide: {
validator () {
@ -99,13 +107,19 @@ export default {
default: undefined
}
},
setup () {
setup (props) {
const clickedRef = useClicked(64)
const clickedPositionRef = useClickPosition()
return {
isMounted: useIsMounted(),
containerRef: ref(null),
mousePosition: computed(() => {
const {
clicked
} = props
if (clicked !== undefined) {
if (clicked) return props.clickPosition
}
if (clickedRef.value) {
return clickedPositionRef.value
}