@dolphinweex/weex-harmony 0.1.93 → 0.1.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -86,6 +86,25 @@ export default {
|
|
|
86
86
|
},
|
|
87
87
|
|
|
88
88
|
methods: {
|
|
89
|
+
/** 判断组件是否可见 */
|
|
90
|
+
isInBrowserViewport() {
|
|
91
|
+
const el = this.$el;
|
|
92
|
+
if (!el || typeof el.getBoundingClientRect !== "function") {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
const rect = el.getBoundingClientRect();
|
|
96
|
+
const vw = window.innerWidth || 0;
|
|
97
|
+
const vh = window.innerHeight || 0;
|
|
98
|
+
if (!vw || !vh) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return (
|
|
102
|
+
rect.bottom > 0 &&
|
|
103
|
+
rect.right > 0 &&
|
|
104
|
+
rect.top < vh &&
|
|
105
|
+
rect.left < vw
|
|
106
|
+
);
|
|
107
|
+
},
|
|
89
108
|
// 自定义拓展其它逻辑
|
|
90
109
|
handleOnChange(res) {
|
|
91
110
|
if (res.mode == 1) {
|
|
@@ -109,7 +128,12 @@ export default {
|
|
|
109
128
|
this.$emit("finish", event || {});
|
|
110
129
|
},
|
|
111
130
|
appear(event) {
|
|
112
|
-
this.$
|
|
131
|
+
this.$nextTick(() => {
|
|
132
|
+
if (!this.isInBrowserViewport()) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
this.$emit("appear", event || {});
|
|
136
|
+
});
|
|
113
137
|
},
|
|
114
138
|
},
|
|
115
139
|
};
|