!41015 挑单 没有帧信号到来时延时触发刷新

Merge pull request !41015 from yihao lin/rele
This commit is contained in:
openharmony_ci 2024-08-25 07:33:45 +00:00 committed by Gitee
commit 60211b061b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 18 additions and 1 deletions

View File

@ -69,6 +69,7 @@ function mergeMaps(stageMap: Map<Symbol, AttributeModifierWithKey>,
class ModifierUtils {
static dirtyComponentSet: Set<ArkComponent | ArkSpanComponent> = new Set();
static dirtyFlag = false;
static timeoutId = -1;
static copyModifierWithKey(obj: ModifierWithKey<string | number | boolean | object>): ModifierWithKey<string | number | boolean | object> {
let newObj: ModifierWithKey<string | number | boolean | object> = {
@ -160,6 +161,9 @@ class ModifierUtils {
static requestFrame(): void {
const frameCallback = () => {
if (this.timeoutId !== -1) {
clearTimeout(this.timeoutId);
}
this.dirtyComponentSet.forEach(item => {
const nativePtrValid = !item._weakPtr.invalid();
if (item._nativePtrChanged && nativePtrValid) {
@ -175,8 +179,12 @@ class ModifierUtils {
});
this.dirtyComponentSet.clear();
this.dirtyFlag = false;
this.timeoutId = -1;
};
if (this.timeoutId !== -1) {
clearTimeout(this.timeoutId);
}
this.timeoutId = setTimeout(frameCallback, 100);
getUINativeModule().frameNode.registerFrameCallback(frameCallback);
}
}

View File

@ -118,6 +118,9 @@ class ModifierUtils {
}
static requestFrame() {
const frameCallback = () => {
if (this.timeoutId !== -1) {
clearTimeout(this.timeoutId);
}
this.dirtyComponentSet.forEach((item) => {
const nativePtrValid = !item._weakPtr.invalid();
if (item._nativePtrChanged && nativePtrValid) {
@ -133,12 +136,18 @@ class ModifierUtils {
});
this.dirtyComponentSet.clear();
this.dirtyFlag = false;
this.timeoutId = -1;
};
if (this.timeoutId !== -1) {
clearTimeout(this.timeoutId);
}
this.timeoutId = setTimeout(frameCallback, 100);
getUINativeModule().frameNode.registerFrameCallback(frameCallback);
}
}
ModifierUtils.dirtyComponentSet = new Set();
ModifierUtils.dirtyFlag = false;
ModifierUtils.timeoutId = -1;
class ModifierMap {
constructor() {
this.map_ = new Map();