Skip to content

Commit 8e796a9

Browse files
author
BearJ
committed
优化 增加actionSheet的onClose回调
1 parent 20bd2fa commit 8e796a9

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

example/example.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ document.querySelector('#actionSheetBtn').addEventListener('click', function ()
7171
}
7272
}
7373
], {
74-
className: "custom-classname"
74+
className: "custom-classname",
75+
onClose: function(){
76+
console.log('关闭');
77+
}
7578
});
7679
});
7780

src/actionSheet/actionSheet.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ let _sington;
5858
* }
5959
* }
6060
* ], {
61-
* className: 'custom-classname'
61+
* className: 'custom-classname',
62+
* onClose: function(){
63+
* console.log('关闭');
64+
* }
6265
* });
6366
*/
6467
function actionSheet(menus = [], actions = [], options = {}) {
@@ -69,7 +72,8 @@ function actionSheet(menus = [], actions = [], options = {}) {
6972
menus: menus,
7073
actions: actions,
7174
className: '',
72-
isAndroid: isAndroid
75+
isAndroid: isAndroid,
76+
onClose: function(){}
7377
}, options);
7478
const $actionSheetWrap = $($.render(tpl, options));
7579
const $actionSheet = $actionSheetWrap.find('.weui-actionsheet');
@@ -84,6 +88,7 @@ function actionSheet(menus = [], actions = [], options = {}) {
8488
.on('animationend webkitAnimationEnd', function () {
8589
$actionSheetWrap.remove();
8690
_sington = false;
91+
options.onClose && options.onClose();
8792
callback && callback();
8893
});
8994
}

0 commit comments

Comments
 (0)