Skip to content

Commit be2a1bf

Browse files
authored
feat(Toast): add transition option (youzan#4638)
1 parent 3e522d3 commit be2a1bf

5 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/toast/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,5 @@ toast2.clear();
127127
| className | Custom className | *any* | - | - |
128128
| onOpened | Callback function after opened | *Function* | - | - |
129129
| onClose | Callback function after close | *Function* | - | - |
130+
| transition | Transition, equivalent to `name` prop of [transtion](https://vuejs.org/v2/api/#transition) | *string* | - | 2.2.6 |
130131
| getContainer | Return the mount node for Toast | *string \| () => Element* | `body` | - |

src/toast/README.zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,5 @@ toast2.clear();
127127
| className | 自定义类名 | *any* | - | - |
128128
| onOpened | 完全展示后的回调函数 | *Function* | - | - |
129129
| onClose | 关闭时的回调函数 | *Function* | - | - |
130+
| transition | 动画类名,等价于 [transtion](https://cn.vuejs.org/v2/api/index.html#transition)`name`属性 | *string* | - | 2.2.6 |
130131
| getContainer | 指定挂载的节点,可以传入选择器,<br>或一个返回节点的函数 | *string \| () => Element* | `body` | - |

src/toast/Toast.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ export default createComponent({
2424
type: String,
2525
default: 'middle'
2626
},
27+
transition: {
28+
type: String,
29+
default: 'van-fade'
30+
},
2731
lockScroll: {
2832
type: Boolean,
2933
default: false
@@ -109,7 +113,7 @@ export default createComponent({
109113

110114
return (
111115
<transition
112-
name="van-fade"
116+
name={this.transition}
113117
onAfterEnter={this.onAfterEnter}
114118
onAfterLeave={this.onAfterLeave}
115119
>

src/toast/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const defaultOptions = {
1414
duration: 3000,
1515
iconPrefix: undefined,
1616
position: 'middle',
17+
transition: 'van-fade',
1718
forbidClick: false,
1819
loadingType: undefined,
1920
getContainer: 'body',

types/toast.d.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ export type ToastOptions = {
77
icon?: string;
88
type?: string;
99
mask?: boolean;
10-
position?: string;
10+
message?: ToastMessage;
11+
onClose?: () => void;
12+
onOpened?: () => void;
1113
duration?: number;
14+
position?: string;
1215
className?: any;
13-
onClose?(): void;
14-
onOpened?(): void;
16+
transition?: string;
17+
loadingType?: string;
1518
forbidClick?: boolean;
1619
closeOnClick?: boolean;
17-
loadingType?: string;
18-
message?: ToastMessage;
1920
getContainer?: string | (() => Element);
2021
};
2122

0 commit comments

Comments
 (0)