!107 UIExtension Adapts to Visible Area Change Events

Merge pull request !107 from amoscloud2013/master
This commit is contained in:
openharmony_ci 2024-09-30 07:12:31 +00:00 committed by Gitee
commit 64c6b6eb69
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -48,6 +48,8 @@ class AdComponent extends ViewPU {
this.eventUniqueId = '';
this.uniqueId = '';
this.uiExtProxy = null;
this.isVisibleBeforeRemoteReady = false;
this.currentRatioBeforeRemoteReady = 0;
this.__showComponent = new ObservedPropertySimplePU(false, this, 'showComponent');
this.__Behavior = new ObservedPropertySimplePU(HitTestMode.Default, this, 'Behavior');
this.__uecHeight = new ObservedPropertySimplePU('100%', this, 'uecHeight');
@ -71,6 +73,8 @@ class AdComponent extends ViewPU {
'eventUniqueId',
'uniqueId',
'uiExtProxy',
'isVisibleBeforeRemoteReady',
'currentRatioBeforeRemoteReady',
'showComponent',
'Behavior',
'uecHeight',
@ -291,6 +295,23 @@ class AdComponent extends ViewPU {
});
UIExtensionComponent.onRemoteReady((v) => {
this.uiExtProxy = v;
v.on('asyncReceiverRegister', (p) => {
p.send({
'isVisible': this.isVisibleBeforeRemoteReady,
'currentRatio': this.currentRatioBeforeRemoteReady,
});
});
});
UIExtensionComponent.onVisibleAreaChange(this.ratios, (v, r) => {
if (this.uiExtProxy) {
this.uiExtProxy.send({
'isVisible': v,
'currentRatio': r,
});
} else {
this.isVisibleBeforeRemoteReady = v;
this.currentRatioBeforeRemoteReady = r;
}
});
UIExtensionComponent.width('100%');
UIExtensionComponent.height(this.uecHeight);
@ -318,11 +339,6 @@ class AdComponent extends ViewPU {
const u = IMP;
this.sendDataRequest(u, w);
}
let p;
(p = this.uiExtProxy) === null || p === void 0 ? void 0 : p.send({
'isVisible': v,
'currentRatio': w,
});
});
Column.onClick(() => this.onAreaClick());
}