Skip to content

Commit 8dcaf08

Browse files
committed
webviewgroup中的页面全部append到父页面,避免退出时闪屏
1 parent 847db84 commit 8dcaf08

File tree

4 files changed

+21
-35
lines changed

4 files changed

+21
-35
lines changed

examples/hello-mui/examples/echarts.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<!--标准mui.css-->
1111
<link rel="stylesheet" href="../css/mui.min.css">
1212
<!--App自定义的css-->
13-
<link rel="stylesheet" type="text/css" href="../css/app.css" />
13+
<!-- <link rel="stylesheet" type="text/css" href="../css/app.css" /> -->
1414
<style>
1515
.chart {
1616
height: 200px;

examples/hello-mui/examples/tab-top-webview-main.html

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ <h1 class="mui-title">顶部选项卡-可左右拖动(webview)</h1>
121121
<a class="mui-control-item" href="#item5mobile" data-wid="tab-top-subpage-5.html">
122122
娱乐
123123
</a>
124-
<!--<a class="mui-control-item" href="#item6mobile" data-wid="tab-top-subpage-6.html">
125-
科技
124+
<!--<a class="mui-control-item" href="#item6mobile" data-wid="tab-top-subpage-6.html">
125+
科技
126126
</a>-->
127127
</div>
128128
</div>
@@ -173,20 +173,7 @@ <h1 class="mui-title">顶部选项卡-可左右拖动(webview)</h1>
173173
});
174174
mui.back = function() {
175175
var _self = plus.webview.currentWebview();
176-
var list = _self.opened();
177-
178-
var top = plus.webview.getTopWebview().id;
179-
for(var i = list.length - 1; i >= 0; i--) {
180-
if(list[i].id == top){
181-
console.log(list[i].id+" is top");
182-
_self.append(list[i]);
183-
}else{
184-
list[i].close("none");
185-
}
186-
}
187-
setTimeout(function () {
188-
_self.close("auto");
189-
},50);
176+
_self.close("auto");
190177
}
191178
</script>
192179
</body>

examples/hello-mui/index.html

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@
387387
</li>
388388
<li class="mui-table-view-cell">
389389
<a class="mui-navigate-right" data-title-type="native" href="examples/tab-vertical-scroll.html">
390-
左侧选项卡-div模式-滚动监听
390+
左侧选项卡-div模式-联动高亮
391391
</a>
392392
</li>
393393
</ul>
@@ -404,8 +404,8 @@
404404
advertisement(广告模板)
405405
</a>
406406
</li>
407-
<li class="mui-table-view-cell ios-only">
408-
<a class="mui-navigate-right" data-title-type="native" href="examples/echarts.html">
407+
<li class="mui-table-view-cell">
408+
<a class="mui-navigate-right" href="examples/echarts.html">
409409
chart(EChart图表)
410410
</a>
411411
</li>
@@ -650,7 +650,7 @@
650650
var webview_style = {
651651
popGesture: "close"
652652
}
653-
653+
var extras = {};
654654
if(titleType == "native") {
655655
if(!~id.indexOf('pullrefresh.html')) {
656656
webview_style.bounce = "vertical";
@@ -699,7 +699,7 @@
699699
webview.evalJS("mui.back();");
700700
}, false);
701701
webview.append(view);
702-
var extras = {};
702+
703703
if(~id.indexOf('im-chat.html')) {
704704
extras.acceleration = "none";
705705
}
@@ -712,18 +712,16 @@
712712
webview_style.zindex = 9998;
713713
webview_style.popGesture = ~id.indexOf('offcanvas-with-right') ? "close" : "none";
714714
}
715-
716-
mui.openWindow({
717-
id: id,
718-
url: this.href,
719-
styles: webview_style,
720-
show: {
721-
aniShow: aniShow,
722-
duration: 300
723-
},
724-
waiting: {
725-
autoShow: false
726-
}
715+
716+
var extras = {};
717+
if(id && id == "viewgroup"){//强制启用截屏
718+
extras.acceleration = "capture";
719+
}
720+
721+
722+
var webview = plus.webview.create(this.href,id,webview_style,extras);
723+
webview.addEventListener("loaded",function () {
724+
webview.show(aniShow,300);
727725
});
728726
}
729727
});

examples/hello-mui/js/webviewGroup.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ proto._dragCallback = function(dir, fromWebview, view, viewId) {
8282
//第一步:初始化目标webview
8383
this.webviewContexts[viewId].createWebview('drag');
8484
var targetWebview = this.webviewContexts[viewId].webview;
85-
//targetWebview.showBehind(plus.webview.getSecondWebview());
8685
targetWebview.show();
8786
this.nativeView.setStyle({
8887
left: '100%'
@@ -249,6 +248,8 @@ _proto.createWebview = function(from) {
249248
plus.nativeUI.showWaiting();
250249
}
251250
this.webview = plus.webview.create(this.url, this.id, options.styles, options.extras);
251+
//append进去,避免返回时闪屏
252+
plus.webview.currentWebview().append(this.webview);
252253
}
253254
this._initWebview();
254255
this.inited = true;

0 commit comments

Comments
 (0)