From c26c15deadba3cf1c7ba11d9c27ce7d648f13379 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Fri, 23 Apr 2021 11:51:30 +0800 Subject: [PATCH] fix: showModal --- packages/uni-core/src/helpers/dom.ts | 6 ++---- packages/uni-h5/dist/uni-h5.esm.js | 18 ++++++++---------- .../uni-h5/src/service/api/ui/popup/modal.tsx | 6 +++--- .../src/service/api/ui/popup/showModal.ts | 11 +++++++---- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/packages/uni-core/src/helpers/dom.ts b/packages/uni-core/src/helpers/dom.ts index 121aed285..f03919c2b 100644 --- a/packages/uni-core/src/helpers/dom.ts +++ b/packages/uni-core/src/helpers/dom.ts @@ -1,10 +1,8 @@ import { withModifiers } from 'vue' import safeAreaInsets from 'safe-area-insets' -export const onTouchmovePrevent = /*#__PURE__*/ withModifiers(() => {}, [ - 'prevent', -]) -export const onTouchmoveStop = /*#__PURE__*/ withModifiers(() => {}, ['stop']) +export const onEventPrevent = /*#__PURE__*/ withModifiers(() => {}, ['prevent']) +export const onEventStop = /*#__PURE__*/ withModifiers(() => {}, ['stop']) export function getWindowOffset() { const style = document.documentElement.style diff --git a/packages/uni-h5/dist/uni-h5.esm.js b/packages/uni-h5/dist/uni-h5.esm.js index aa8698f6b..f19a6d3f9 100644 --- a/packages/uni-h5/dist/uni-h5.esm.js +++ b/packages/uni-h5/dist/uni-h5.esm.js @@ -623,11 +623,9 @@ var safeAreaInsets = { offChange }; var out = safeAreaInsets; -const onTouchmovePrevent = /* @__PURE__ */ withModifiers(() => { -}, [ - "prevent" -]); -const onTouchmoveStop = /* @__PURE__ */ withModifiers(() => { +const onEventPrevent = /* @__PURE__ */ withModifiers(() => { +}, ["prevent"]); +const onEventStop = /* @__PURE__ */ withModifiers(() => { }, ["stop"]); function getWindowOffset() { const style2 = document.documentElement.style; @@ -12848,7 +12846,7 @@ var modal = /* @__PURE__ */ defineComponent({ name: "uni-fade" }, { default: () => [withDirectives(createVNode("uni-modal", { - onTouchmove: onTouchmovePrevent + onTouchmove: onEventPrevent }, [VNODE_MASK, createVNode("div", { class: "uni-modal" }, [title && createVNode("div", { @@ -12858,9 +12856,9 @@ var modal = /* @__PURE__ */ defineComponent({ textContent: title }, null, 8, ["textContent"])]), createVNode("div", { class: "uni-modal__bd", - onTouchmove: onTouchmoveStop, + onTouchmovePassive: onEventStop, textContent: content - }, null, 40, ["onTouchmove", "textContent"]), createVNode("div", { + }, null, 40, ["onTouchmovePassive", "textContent"]), createVNode("div", { class: "uni-modal__ft" }, [showCancel && createVNode("div", { style: { @@ -12891,11 +12889,11 @@ const showModal = defineAsyncApi(API_SHOW_MODAL, (args, {resolve}) => { currentShowModalResolve = resolve; if (!showModalState) { showModalState = reactive(args); - nextTick(() => createRootApp(modal, showModalState, onModalClose).mount(ensureRoot("u-a-m"))); + nextTick(() => (createRootApp(modal, showModalState, onModalClose).mount(ensureRoot("u-a-m")), nextTick(() => showModalState.visible = true))); } else { extend(showModalState, args); + showModalState.visible = true; } - showModalState.visible = true; }, ShowModalProtocol, ShowModalOptions); const loadFontFace = defineAsyncApi(API_LOAD_FONT_FACE, ({family, source, desc}, {resolve, reject}) => { addFont(family, source, desc).then(() => { diff --git a/packages/uni-h5/src/service/api/ui/popup/modal.tsx b/packages/uni-h5/src/service/api/ui/popup/modal.tsx index 78c82bcf6..2e120cc48 100644 --- a/packages/uni-h5/src/service/api/ui/popup/modal.tsx +++ b/packages/uni-h5/src/service/api/ui/popup/modal.tsx @@ -1,4 +1,4 @@ -import { onTouchmovePrevent, onTouchmoveStop } from '@dcloudio/uni-core' +import { onEventPrevent, onEventStop } from '@dcloudio/uni-core' import { Transition, defineComponent, ExtractPropTypes } from 'vue' import { usePopup, VNODE_MASK } from './utils' @@ -51,7 +51,7 @@ export default /*#__PURE__*/ defineComponent({ const { title, content, showCancel, confirmText, confirmColor } = props return ( - + {VNODE_MASK}
{title && ( @@ -61,7 +61,7 @@ export default /*#__PURE__*/ defineComponent({ )}
diff --git a/packages/uni-h5/src/service/api/ui/popup/showModal.ts b/packages/uni-h5/src/service/api/ui/popup/showModal.ts index 5ee06060e..7ce3db69f 100644 --- a/packages/uni-h5/src/service/api/ui/popup/showModal.ts +++ b/packages/uni-h5/src/service/api/ui/popup/showModal.ts @@ -31,15 +31,18 @@ export const showModal = defineAsyncApi( if (!showModalState) { showModalState = reactive(args as ModalProps) // 异步执行,避免干扰 getCurrentInstance - nextTick(() => - createRootApp(modal, showModalState, onModalClose).mount( - ensureRoot('u-a-m') + nextTick( + () => ( + createRootApp(modal, showModalState, onModalClose).mount( + ensureRoot('u-a-m') + ), //下一帧执行,确保首次显示时有动画效果 + nextTick(() => (showModalState.visible = true)) ) ) } else { extend(showModalState, args) + showModalState.visible = true } - showModalState.visible = true }, ShowModalProtocol, ShowModalOptions -- GitLab