mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 11:20:11 +00:00
feat: use "ric-shim" replace "window.requestIdleCallback" fix #829
This commit is contained in:
parent
6cb0df3209
commit
80be82af6a
@ -24,6 +24,7 @@
|
||||
"enzyme-adapter-react-16": "^1.15.5",
|
||||
"react": "^16",
|
||||
"react-dom": "^16.7.0",
|
||||
"ric-shim": "^1.0.1",
|
||||
"semver": "^7.3.5",
|
||||
"zen-logger": "^1.1.0"
|
||||
},
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import requestIdleCallback, { cancelIdleCallback } from 'ric-shim';
|
||||
import { obx, computed, makeObservable } from '@alilc/lowcode-editor-core';
|
||||
import { uniqueId } from '@alilc/lowcode-utils';
|
||||
import { INodeSelector, IViewport } from '../simulator';
|
||||
@ -136,7 +137,7 @@ export class OffsetObserver {
|
||||
this._bottom = rect.bottom;
|
||||
this.hasOffset = true;
|
||||
}
|
||||
this.pid = (window as any).requestIdleCallback(compute);
|
||||
this.pid = requestIdleCallback(compute);
|
||||
pid = this.pid;
|
||||
};
|
||||
|
||||
@ -145,13 +146,13 @@ export class OffsetObserver {
|
||||
// try first
|
||||
compute();
|
||||
// try second, ensure the dom mounted
|
||||
this.pid = (window as any).requestIdleCallback(compute);
|
||||
this.pid = requestIdleCallback(compute);
|
||||
pid = this.pid;
|
||||
}
|
||||
|
||||
purge() {
|
||||
if (this.pid) {
|
||||
(window as any).cancelIdleCallback(this.pid);
|
||||
cancelIdleCallback(this.pid);
|
||||
}
|
||||
this.pid = undefined;
|
||||
}
|
||||
|
||||
@ -19,7 +19,8 @@
|
||||
"@alilc/lowcode-utils": "1.0.15",
|
||||
"classnames": "^2.2.6",
|
||||
"react": "^16",
|
||||
"react-dom": "^16.7.0"
|
||||
"react-dom": "^16.7.0",
|
||||
"ric-shim": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@alib/build-scripts": "^0.1.18",
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import requestIdleCallback, { cancelIdleCallback } from 'ric-shim';
|
||||
import { computed, makeObservable, obx } from '@alilc/lowcode-editor-core';
|
||||
import {
|
||||
Designer,
|
||||
@ -495,7 +496,7 @@ export class OutlineMain implements ISensor, ITreeBoard, IScrollable {
|
||||
*/
|
||||
scrollToNode(treeNode: TreeNode, detail?: any, tryTimes = 0) {
|
||||
if (tryTimes < 1 && this.tryScrollAgain) {
|
||||
(window as any).cancelIdleCallback(this.tryScrollAgain);
|
||||
cancelIdleCallback(this.tryScrollAgain);
|
||||
this.tryScrollAgain = null;
|
||||
}
|
||||
if (this.sensing || !this.bounds || !this.scroller || !this.scrollTarget) {
|
||||
@ -512,7 +513,7 @@ export class OutlineMain implements ISensor, ITreeBoard, IScrollable {
|
||||
|
||||
if (!rect) {
|
||||
if (tryTimes < 3) {
|
||||
this.tryScrollAgain = (window as any).requestIdleCallback(() => this.scrollToNode(treeNode, detail, tryTimes + 1));
|
||||
this.tryScrollAgain = requestIdleCallback(() => this.scrollToNode(treeNode, detail, tryTimes + 1));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -528,7 +529,7 @@ export class OutlineMain implements ISensor, ITreeBoard, IScrollable {
|
||||
}
|
||||
// make tail scroll be sure
|
||||
if (tryTimes < 4) {
|
||||
this.tryScrollAgain = (window as any).requestIdleCallback(() => this.scrollToNode(treeNode, detail, 4));
|
||||
this.tryScrollAgain = requestIdleCallback(() => this.scrollToNode(treeNode, detail, 4));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user