@alipay/ams-checkout 0.0.1749206034-dev.0 → 0.0.1749206034-dev.1
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.
@@ -13,6 +13,7 @@ export declare class ContainerService implements Service {
|
|
13
13
|
private webApp;
|
14
14
|
private _webAppHeartBeatTimeoutFn;
|
15
15
|
private clientHeight;
|
16
|
+
private boundFocusResizeChange;
|
16
17
|
private customizedLoadingListener;
|
17
18
|
destroy(): void;
|
18
19
|
init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
|
@@ -36,6 +36,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
36
36
|
_defineProperty(this, "webApp", void 0);
|
37
37
|
_defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
|
38
38
|
_defineProperty(this, "clientHeight", void 0);
|
39
|
+
_defineProperty(this, "boundFocusResizeChange", void 0);
|
39
40
|
// if this variable is true, SDK will invoke listener instead of showing loading
|
40
41
|
_defineProperty(this, "customizedLoadingListener", void 0);
|
41
42
|
}
|
@@ -57,6 +58,8 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
57
58
|
this.addCapabilityToEventCenter();
|
58
59
|
}
|
59
60
|
this.addCapabilityToApiBusManager();
|
61
|
+
// bind会返回一个新的方法,init时记录上这个focus,不然window.addEventListener时this指向会变成window
|
62
|
+
this.boundFocusResizeChange = this.focusResizeChange.bind(this);
|
60
63
|
}
|
61
64
|
}, {
|
62
65
|
key: "update",
|
@@ -163,15 +166,15 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
163
166
|
value: function handleAccountFocus(focus) {
|
164
167
|
var _window$visualViewpor, _window;
|
165
168
|
// 失焦时v2会走默认的sizeChange还原高度,这里仅移除监听
|
166
|
-
(_window$visualViewpor = window.visualViewport) === null || _window$visualViewpor === void 0 || _window$visualViewpor.removeEventListener('resize', this.
|
167
|
-
(_window = window) === null || _window === void 0 || _window.removeEventListener('resize', this.
|
169
|
+
(_window$visualViewpor = window.visualViewport) === null || _window$visualViewpor === void 0 || _window$visualViewpor.removeEventListener('resize', this.boundFocusResizeChange);
|
170
|
+
(_window = window) === null || _window === void 0 || _window.removeEventListener('resize', this.boundFocusResizeChange);
|
168
171
|
// 只有聚焦才监听,失焦后移除,避免影响别的场景
|
169
172
|
if (focus) {
|
170
173
|
var _window$visualViewpor2;
|
171
174
|
// 监听页面visualViewport的高度变化,适用于主流机型更精准获取当前页面高度
|
172
|
-
(_window$visualViewpor2 = window.visualViewport) === null || _window$visualViewpor2 === void 0 || _window$visualViewpor2.addEventListener('resize', this.
|
175
|
+
(_window$visualViewpor2 = window.visualViewport) === null || _window$visualViewpor2 === void 0 || _window$visualViewpor2.addEventListener('resize', this.boundFocusResizeChange);
|
173
176
|
// 兼容visualViewport处理不到的场景,一般存在于老版本浏览器
|
174
|
-
window.addEventListener('resize', this.
|
177
|
+
window.addEventListener('resize', this.boundFocusResizeChange);
|
175
178
|
}
|
176
179
|
}
|
177
180
|
}, {
|
@@ -309,9 +312,11 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
309
312
|
var _window2;
|
310
313
|
// 计算出当前iframe应有的高度,需要和顶部留有距离
|
311
314
|
var webPageHeightRatio = 0.9;
|
315
|
+
var browserPageHeightFocusRatio = 0.9;
|
312
316
|
// sdk层才能拿到当前键盘弹起后页面的高度
|
313
317
|
var height = ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.visualViewport) === null || _window2 === void 0 ? void 0 : _window2.height) || window.innerHeight;
|
314
318
|
height = height * webPageHeightRatio;
|
319
|
+
height = height * browserPageHeightFocusRatio;
|
315
320
|
// 调用handleSizeChanged修改iframe高度
|
316
321
|
this.handleSizeChanged({
|
317
322
|
width: 0,
|
@@ -335,12 +340,12 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
335
340
|
if (!cashier) return;
|
336
341
|
// 输入框聚焦时修改定位信息和top距离
|
337
342
|
if (focus) {
|
338
|
-
cashier.style.position
|
339
|
-
cashier.style.top
|
343
|
+
cashier.style.setProperty('position', 'fixed', 'important');
|
344
|
+
cashier.style.setProperty('top', "".concat(this.clientHeight - cashier.clientHeight, "px"), 'important');
|
340
345
|
} else {
|
341
346
|
// 失焦时移除定位信息
|
342
|
-
cashier.style.position
|
343
|
-
cashier.style.top
|
347
|
+
cashier.style.removeProperty('position');
|
348
|
+
cashier.style.removeProperty('top');
|
344
349
|
}
|
345
350
|
}
|
346
351
|
}, {
|