Skip to content
Open
Changes from all 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
6 changes: 4 additions & 2 deletions src/cubic-bezier/view/cubic-bezier-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class CubicBezierPreviewView implements View {
private readonly value_: Value<CubicBezier>;
private stopped_ = true;
private startTime_ = -1;
private requestId_ = -1;

constructor(doc: Document, config: Config) {
this.onDispose_ = this.onDispose_.bind(this);
Expand Down Expand Up @@ -71,10 +72,11 @@ export class CubicBezierPreviewView implements View {

this.startTime_ = new Date().getTime() + PREVIEW_DELAY;
this.stopped_ = false;
requestAnimationFrame(this.onTimer_);
this.requestId_ = requestAnimationFrame(this.onTimer_);
}

public stop(): void {
cancelAnimationFrame(this.requestId_);
this.stopped_ = true;
this.markerElem_.classList.remove(className('m', 'a'));
}
Expand Down Expand Up @@ -114,7 +116,7 @@ export class CubicBezierPreviewView implements View {
}

if (!this.stopped_) {
requestAnimationFrame(this.onTimer_);
this.requestId_ = requestAnimationFrame(this.onTimer_);
}
}

Expand Down