Skip to content

Commit

Permalink
fix mask no transition bug (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
sklme authored and progrape committed Apr 21, 2016
1 parent 3a6eaf7 commit 775502c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions dist/example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,20 @@ $(function () {
var mask = $('#mask');
var weuiActionsheet = $('#weui_actionsheet');
weuiActionsheet.addClass('weui_actionsheet_toggle');
mask.show().addClass('weui_fade_toggle').one('click', function () {
mask.show()
.focus()//加focus是为了触发一次页面的重排(reflow or layout thrashing),使mask的transition动画得以正常触发
.addClass('weui_fade_toggle').one('click', function () {
hideActionSheet(weuiActionsheet, mask);
});
$('#actionsheet_cancel').one('click', function () {
hideActionSheet(weuiActionsheet, mask);
});
weuiActionsheet.unbind('transitionend').unbind('webkitTransitionEnd');
mask.unbind('transitionend').unbind('webkitTransitionEnd');

function hideActionSheet(weuiActionsheet, mask) {
weuiActionsheet.removeClass('weui_actionsheet_toggle');
mask.removeClass('weui_fade_toggle');
weuiActionsheet.on('transitionend', function () {
mask.on('transitionend', function () {
mask.hide();
}).on('webkitTransitionEnd', function () {
mask.hide();
Expand Down
8 changes: 5 additions & 3 deletions src/example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,20 @@ $(function () {
var mask = $('#mask');
var weuiActionsheet = $('#weui_actionsheet');
weuiActionsheet.addClass('weui_actionsheet_toggle');
mask.show().addClass('weui_fade_toggle').one('click', function () {
mask.show()
.focus()//加focus是为了触发一次页面的重排(reflow or layout thrashing),使mask的transition动画得以正常触发
.addClass('weui_fade_toggle').one('click', function () {
hideActionSheet(weuiActionsheet, mask);
});
$('#actionsheet_cancel').one('click', function () {
hideActionSheet(weuiActionsheet, mask);
});
weuiActionsheet.unbind('transitionend').unbind('webkitTransitionEnd');
mask.unbind('transitionend').unbind('webkitTransitionEnd');

function hideActionSheet(weuiActionsheet, mask) {
weuiActionsheet.removeClass('weui_actionsheet_toggle');
mask.removeClass('weui_fade_toggle');
weuiActionsheet.on('transitionend', function () {
mask.on('transitionend', function () {
mask.hide();
}).on('webkitTransitionEnd', function () {
mask.hide();
Expand Down

0 comments on commit 775502c

Please sign in to comment.