Skip to content

Commit 3e522d3

Browse files
authored
feat(Dialog): add transition prop (youzan#4636)
1 parent 1926d3a commit 3e522d3

5 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/dialog/Dialog.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export default createComponent({
2121
confirmButtonText: String,
2222
confirmButtonColor: String,
2323
showCancelButton: Boolean,
24+
transition: {
25+
type: String,
26+
default: 'van-dialog-bounce'
27+
},
2428
showConfirmButton: {
2529
type: Boolean,
2630
default: true
@@ -140,7 +144,7 @@ export default createComponent({
140144

141145
return (
142146
<transition
143-
name="van-dialog-bounce"
147+
name={this.transition}
144148
onAfterEnter={this.onOpened}
145149
onAfterLeave={this.onClosed}
146150
>

src/dialog/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export default {
133133
| closeOnClickOverlay | Whether to close when click overlay | *boolean* | `false` | - |
134134
| lockScroll | Whether to lock body scroll | *boolean* | `true` | - |
135135
| beforeClose | Callback before close,<br>call done() to close dialog,<br>call done(false) to cancel loading | (action: string, done: Function) => void | - | - |
136+
| transition | Transition, equivalent to `name` prop of [transtion](https://vuejs.org/v2/api/#transition) | *string* | - | 2.2.6 |
136137
| getContainer | Return the mount node for Dialog | *string \| () => Element* | `body` | - |
137138

138139
### Props
@@ -154,6 +155,7 @@ export default {
154155
| close-on-click-overlay | Whether to close when click overlay | *boolean* | `false` | - |
155156
| lock-scroll | Whether to lock background scroll | *boolean* | `true` | - |
156157
| before-close | Callback before close,<br>call done() to close dialog,<br>call done(false) to cancel loading | (action: string, done: Function) => void | - | - |
158+
| transition | Transition, equivalent to `name` prop of [transtion](https://vuejs.org/v2/api/#transition) | *string* | - | 2.2.6 |
157159
| get-container | Return the mount node for Dialog | *string \| () => Element* | - | - |
158160

159161
### Events

src/dialog/README.zh-CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export default {
162162
| closeOnClickOverlay | 是否在点击遮罩层后关闭弹窗 | *boolean* | `false` | - |
163163
| lockScroll | 是否锁定背景滚动 | *boolean* | `true` | - |
164164
| beforeClose | 关闭前的回调函数,<br>调用 done() 后关闭弹窗,<br>调用 done(false) 阻止弹窗关闭 | *(action, done) => void* | - | - |
165+
| transition | 动画类名,等价于 [transtion](https://cn.vuejs.org/v2/api/index.html#transition)`name`属性 | *string* | - | 2.2.6 |
165166
| getContainer | 指定挂载的节点,可以传入选择器,<br>或一个返回节点的函数 | *string \| () => Element* | `body` | - |
166167

167168
### Props
@@ -185,6 +186,7 @@ export default {
185186
| close-on-click-overlay | 是否在点击遮罩层后关闭弹窗 | *boolean* | `false` | - |
186187
| lock-scroll | 是否锁定背景滚动 | *boolean* | `true` | - |
187188
| before-close | 关闭前的回调函数,<br>调用 done() 后关闭弹窗,<br>调用 done(false) 阻止弹窗关闭 | *(action, done) => void* | - | - |
189+
| transition | 动画类名,等价于 [transtion](https://cn.vuejs.org/v2/api/index.html#transition)`name`属性 | *string* | - | 2.2.6 |
188190
| get-container | 指定挂载的节点,可以传入选择器,<br>或一个返回节点的函数 | *string \| () => Element* | - | - |
189191

190192
### Events

src/dialog/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Dialog.defaultOptions = {
5151
overlay: true,
5252
className: '',
5353
lockScroll: true,
54+
transition: 'van-dialog-bounce',
5455
beforeClose: null,
5556
messageAlign: '',
5657
getContainer: 'body',

types/dialog.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type DialogOptions = {
77
overlay?: boolean;
88
className?: any;
99
lockScroll?: boolean;
10+
transition?: string;
1011
messageAlign?: string;
1112
closeOnPopstate?: boolean;
1213
cancelButtonText?: string;

0 commit comments

Comments
 (0)