Skip to content

Commit 7afef93

Browse files
committed
notebookbar overflow: throttle resizing
- if we are faster we can spin tasks more dense - in case of resizing in Chrome I experienced more jitter in animation - after profiling I saw reduced overhead of single overflow management but it happened more often while rapid or long resize distance - this change makes us sure that we don't repeat tasks unnecessary Signed-off-by: Szymon Kłos <[email protected]> Change-Id: I8a40dfb4574bb9ca77524b19826fb9b15061d9cc
1 parent a87122b commit 7afef93

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

browser/src/control/jsdialog/Widget.OverflowManager.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class OverflowManager {
1919
parentContainer: HTMLElement;
2020
data: ContainerWidgetJSON;
2121
lastMaxWidth: number = -1;
22+
scheduledRefresh: boolean = false;
2223

2324
constructor(parentContainer: Element, data: ContainerWidgetJSON) {
2425
this.parentContainer = parentContainer as HTMLElement;
@@ -66,11 +67,15 @@ class OverflowManager {
6667
}
6768

6869
onResize(event: Event) {
69-
app.layoutingService.appendLayoutingTask(() => this.onRefresh(event));
70+
if (!this.scheduledRefresh) {
71+
app.layoutingService.appendLayoutingTask(() => this.onRefresh(event));
72+
this.scheduledRefresh = true;
73+
}
7074
}
7175

7276
// sometimes we want to call it synchronously as it is already in the task (tab switch)
7377
onRefresh(event: Event & { force?: boolean }) {
78+
this.scheduledRefresh = false;
7479
if (!this.parentContainer) return;
7580
if (this.lastMaxWidth === window.innerWidth) return;
7681

0 commit comments

Comments
 (0)