Skip to content

Commit f3a0082

Browse files
committed
更新webviewGroup,动态计算nativeView高度
1 parent 64063f1 commit f3a0082

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

examples/hello-mui/js/webviewGroup.js

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ proto._initParent = function() {
2828
}
2929
};
3030
proto._initNativeView = function() {
31-
this.nativeView = new plus.nativeObj.View('__W2A_TAB_NATIVE', {
32-
'top': '83px',
33-
'bottom': "0px",
31+
this.nativeView = new plus.nativeObj.View('__MUI_TAB_NATIVE', {
32+
'top': '83px',//这个需要根据顶部导航及顶部选项卡高度自动调整
33+
'height': (window.screen.height - 83)+"px",
3434
'left': '100%',
3535
'width': '100%',
36-
'backgroudColor': '#ffffff'
36+
"backgroundColor":"#ffffff"
3737
});
3838
this.nativeView.show();
3939
};
@@ -45,11 +45,11 @@ proto._initWebviewContexts = function() {
4545
var isLast = i === (len - 1);
4646
var isCurrent = this.options.index === i;
4747
var extras = webviewOptions.extras;
48-
extras.__wap2app_url = webviewOptions.url;
49-
extras.__wap2app_index = i;
48+
extras.__mui_url = webviewOptions.url;
49+
extras.__mui_index = i;
5050

51-
extras.__wap2app_left = isFirst ? '' : this.items[i - 1].id;
52-
extras.__wap2app_right = isLast ? '' : this.items[i + 1].id;
51+
extras.__mui_left = isFirst ? '' : this.items[i - 1].id;
52+
extras.__mui_right = isLast ? '' : this.items[i + 1].id;
5353

5454
var styles = webviewOptions.styles || {};
5555

@@ -74,7 +74,7 @@ proto._initWebviewContexts = function() {
7474
proto._onChange = function(webview) {
7575
this.currentWebview = webview;
7676
this.onChange({
77-
index: webview.__wap2app_index
77+
index: webview.__mui_index
7878
});
7979
};
8080
proto._dragCallback = function(dir, fromWebview, view, viewId) {
@@ -97,11 +97,11 @@ proto._dragCallback = function(dir, fromWebview, view, viewId) {
9797
};
9898

9999
proto._initDrag = function(webview, dir) {
100-
var flag = ('__wap2app_drag_' + dir + '_flag');
100+
var flag = ('__mui_drag_' + dir + '_flag');
101101
if(webview[flag]) {
102102
return;
103103
}
104-
var viewId = webview['__wap2app_' + (dir === 'left' ? 'right' : 'left')];
104+
var viewId = webview['__mui_' + (dir === 'left' ? 'right' : 'left')];
105105
if(viewId) {
106106
var view = plus.webview.getWebviewById(viewId);
107107
if(!view) { //如果目标webview不存在,使用nativeView替换
@@ -131,17 +131,17 @@ proto._initDrags = function(webview) {
131131
this._initDrag(webview, 'right');
132132
};
133133
proto._checkDrags = function(webview) {
134-
var left = webview.__wap2app_left;
135-
var right = webview.__wap2app_right;
134+
var left = webview.__mui_left;
135+
var right = webview.__mui_right;
136136
if(left) {
137137
var leftWebview = plus.webview.getWebviewById(left);
138-
if(leftWebview && !leftWebview.__wap2app_drag_left_flag) {
138+
if(leftWebview && !leftWebview.__mui_drag_left_flag) {
139139
this._initDrag(leftWebview, 'left');
140140
}
141141
}
142142
if(right) {
143143
var rightWebview = plus.webview.getWebviewById(right);
144-
if(rightWebview && !rightWebview.__wap2app_drag_right_flag) {
144+
if(rightWebview && !rightWebview.__mui_drag_right_flag) {
145145
this._initDrag(rightWebview, 'right');
146146
}
147147
}
@@ -165,7 +165,7 @@ proto.switchTab = function(id) {
165165
var toWebview = toWebviewContext.webview;
166166
var fromToLeft = '100%';
167167
var toFromLeft = '-100%';
168-
if(toWebviewContext.options.extras.__wap2app_index > fromWebview.__wap2app_index) {
168+
if(toWebviewContext.options.extras.__mui_index > fromWebview.__mui_index) {
169169
fromToLeft = '-100%';
170170
toFromLeft = '100%';
171171
}
@@ -180,11 +180,9 @@ proto.switchTab = function(id) {
180180
this._checkDrags(toWebview); //新建的时候均需校验
181181
}
182182
var self = this;
183-
// toWebview.show("none");
184-
console.log("current:" + fromWebview.id + ",to:" + fromToLeft);
185-
console.log("next:" + toWebview.id + ",from:" + toFromLeft);
183+
// console.log("current:" + fromWebview.id + ",to:" + fromToLeft);
184+
// console.log("next:" + toWebview.id + ",from:" + toFromLeft);
186185

187-
// console.log("current_fromToLeft:"+fromToLeft+",nexttoFromLeft:"+toFromLeft);
188186
plus.webview.startAnimation({
189187
'view': fromWebview,
190188
'styles': {
@@ -201,11 +199,12 @@ proto.switchTab = function(id) {
201199
'action': 'show'
202200
},
203201
function(e) {
202+
//console.log("startAnimation callback...");
204203
if(e.id === toWebview.id) {
205204
isNew && plus.nativeUI.showWaiting();
206205
this.currentWebview = toWebview;
207206
this.onChange({
208-
index: toWebview.__wap2app_index
207+
index: toWebview.__mui_index
209208
});
210209
}
211210
}.bind(this)

0 commit comments

Comments
 (0)