Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cursor blink lags when pointer down at text range #4180

Merged
merged 4 commits into from
Nov 29, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions packages/docs-ui/src/services/selection/text-range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,23 @@ export class TextRange implements IDocRange {
}

private _anchorBlink() {
setTimeout(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥删除这个呢?这个是为了 500ms 后隐藏

if (this._anchorShape) {
if (this._anchorShape.visible) {
this.deactivateStatic();
}
}
}, BLINK_ON);

this._anchorBlinkTimer = setInterval(() => {
const tickFn = () => {
if (this._anchorShape) {
if (this._anchorShape.visible) {
this.activeStatic();

setTimeout(() => {
this.deactivateStatic();
}, BLINK_ON);
}
}
}, BLINK_OFF + BLINK_ON);
};

// wait for anchorShape created.
setTimeout(() => {
lumixraku marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有了下面 make dirty 是不是不用setTimeout 呢

tickFn();
}, 0);

this._anchorBlinkTimer = setInterval(tickFn, BLINK_OFF + BLINK_ON);
}

// The start position of the range
Expand Down Expand Up @@ -476,7 +474,6 @@ export class TextRange implements IDocRange {
}

this._anchorShape = anchor;

this._scene.addObject(anchor, TEXT_RANGE_LAYER_INDEX);
}

Expand Down