|
@@ -7,6 +7,8 @@ |
|
@@ -7,6 +7,8 @@ |
7
|
|
7
|
|
8
|
'use strict';
|
8
|
'use strict';
|
9
|
|
9
|
|
|
|
10
|
+const $ = require('yoho-jquery');
|
|
|
11
|
+
|
10
|
const ANIMATIONS = {
|
12
|
const ANIMATIONS = {
|
11
|
none: {
|
13
|
none: {
|
12
|
in: 'overlay-in',
|
14
|
in: 'overlay-in',
|
|
@@ -66,6 +68,18 @@ class Overlay { |
|
@@ -66,6 +68,18 @@ class Overlay { |
66
|
.removeClass(this.settings.animationClasses.out);
|
68
|
.removeClass(this.settings.animationClasses.out);
|
67
|
}
|
69
|
}
|
68
|
|
70
|
|
|
|
71
|
+ _cleanupListener() {
|
|
|
72
|
+ this.elem.css({
|
|
|
73
|
+ visibility: 'hidden'
|
|
|
74
|
+ });
|
|
|
75
|
+ this._clearStylesClasses();
|
|
|
76
|
+ this.isVisible = false;
|
|
|
77
|
+ this.elem.detach();
|
|
|
78
|
+
|
|
|
79
|
+ // 一次性监听,动画完成事件触发后删除监听器
|
|
|
80
|
+ this.elem[0].removeEventListener('webkitTransitionEnd', this._cleanupListener);
|
|
|
81
|
+ }
|
|
|
82
|
+
|
69
|
/**
|
83
|
/**
|
70
|
* 显示覆盖层
|
84
|
* 显示覆盖层
|
71
|
*/
|
85
|
*/
|
|
@@ -95,19 +109,8 @@ class Overlay { |
|
@@ -95,19 +109,8 @@ class Overlay { |
95
|
hide() {
|
109
|
hide() {
|
96
|
if (this.isVisible) {
|
110
|
if (this.isVisible) {
|
97
|
this._clearStylesClasses();
|
111
|
this._clearStylesClasses();
|
98
|
- const listener = () => {
|
|
|
99
|
- this.elem.css({
|
|
|
100
|
- visibility: 'hidden'
|
|
|
101
|
- });
|
|
|
102
|
- this._clearStylesClasses();
|
|
|
103
|
- this.isVisible = false;
|
|
|
104
|
- this.elem.detach();
|
|
|
105
|
|
112
|
|
106
|
- // 一次性监听,动画完成事件触发后删除监听器
|
|
|
107
|
- this.elem[0].removeEventListener('webkitTransitionEnd', listener);
|
|
|
108
|
- };
|
|
|
109
|
-
|
|
|
110
|
- this.elem[0].addEventListener('webkitTransitionEnd', listener);
|
113
|
+ this.elem[0].addEventListener('webkitTransitionEnd', this._cleanupListener.bind(this));
|
111
|
this.elem.addClass(this.settings.animationClasses.out);
|
114
|
this.elem.addClass(this.settings.animationClasses.out);
|
112
|
|
115
|
|
113
|
if (this.settings.disableScrolling) {
|
116
|
if (this.settings.disableScrolling) {
|
|
@@ -116,6 +119,10 @@ class Overlay { |
|
@@ -116,6 +119,10 @@ class Overlay { |
116
|
});
|
119
|
});
|
117
|
}
|
120
|
}
|
118
|
|
121
|
|
|
|
122
|
+ setTimeout(()=> {
|
|
|
123
|
+ this._cleanupListener();
|
|
|
124
|
+ }, 100);
|
|
|
125
|
+
|
119
|
this.settings.onClose();
|
126
|
this.settings.onClose();
|
120
|
}
|
127
|
}
|
121
|
}
|
128
|
}
|