From be2a1bf91cffc3ed926a4acd24635c7381ee4ae5 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 3 Oct 2019 08:51:50 +0800 Subject: [PATCH] feat(Toast): add transition option (#4638) --- src/toast/README.md | 1 + src/toast/README.zh-CN.md | 1 + src/toast/Toast.js | 6 +++++- src/toast/index.js | 1 + types/toast.d.ts | 11 ++++++----- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/toast/README.md b/src/toast/README.md index 1853f10cb..27652a4b7 100644 --- a/src/toast/README.md +++ b/src/toast/README.md @@ -127,4 +127,5 @@ toast2.clear(); | className | Custom className | *any* | - | - | | onOpened | Callback function after opened | *Function* | - | - | | onClose | Callback function after close | *Function* | - | - | +| transition | Transition, equivalent to `name` prop of [transtion](https://vuejs.org/v2/api/#transition) | *string* | - | 2.2.6 | | getContainer | Return the mount node for Toast | *string \| () => Element* | `body` | - | diff --git a/src/toast/README.zh-CN.md b/src/toast/README.zh-CN.md index ebbe852d4..42ead1c72 100644 --- a/src/toast/README.zh-CN.md +++ b/src/toast/README.zh-CN.md @@ -127,4 +127,5 @@ toast2.clear(); | className | 自定义类名 | *any* | - | - | | onOpened | 完全展示后的回调函数 | *Function* | - | - | | onClose | 关闭时的回调函数 | *Function* | - | - | +| transition | 动画类名,等价于 [transtion](https://cn.vuejs.org/v2/api/index.html#transition) 的`name`属性 | *string* | - | 2.2.6 | | getContainer | 指定挂载的节点,可以传入选择器,
或一个返回节点的函数 | *string \| () => Element* | `body` | - | diff --git a/src/toast/Toast.js b/src/toast/Toast.js index e997ad2b3..0e842cf43 100644 --- a/src/toast/Toast.js +++ b/src/toast/Toast.js @@ -24,6 +24,10 @@ export default createComponent({ type: String, default: 'middle' }, + transition: { + type: String, + default: 'van-fade' + }, lockScroll: { type: Boolean, default: false @@ -109,7 +113,7 @@ export default createComponent({ return ( diff --git a/src/toast/index.js b/src/toast/index.js index 6d1525c01..18950dd6b 100644 --- a/src/toast/index.js +++ b/src/toast/index.js @@ -14,6 +14,7 @@ const defaultOptions = { duration: 3000, iconPrefix: undefined, position: 'middle', + transition: 'van-fade', forbidClick: false, loadingType: undefined, getContainer: 'body', diff --git a/types/toast.d.ts b/types/toast.d.ts index d28079da7..7fba8a938 100644 --- a/types/toast.d.ts +++ b/types/toast.d.ts @@ -7,15 +7,16 @@ export type ToastOptions = { icon?: string; type?: string; mask?: boolean; - position?: string; + message?: ToastMessage; + onClose?: () => void; + onOpened?: () => void; duration?: number; + position?: string; className?: any; - onClose?(): void; - onOpened?(): void; + transition?: string; + loadingType?: string; forbidClick?: boolean; closeOnClick?: boolean; - loadingType?: string; - message?: ToastMessage; getContainer?: string | (() => Element); };