Skip to content

Commit

Permalink
Add a new API to stop scroll #2864
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed May 4, 2021
1 parent 0aa6dcd commit 2d75bc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions webextensions/common/tst-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const kTOGGLE_TREE_COLLAPSED = 'toggle-tree-collapsed';
export const kADD_TAB_STATE = 'add-tab-state';
export const kREMOVE_TAB_STATE = 'remove-tab-state';
export const kSCROLL = 'scroll';
export const kSTOP_SCROLL = 'stop-scroll';
export const kSCROLL_LOCK = 'scroll-lock';
export const kSCROLL_UNLOCK = 'scroll-unlock';
export const kNOTIFY_SCROLLED = 'scrolled';
Expand Down
16 changes: 16 additions & 0 deletions webextensions/sidebar/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,22 @@ function onMessageExternal(message, _aSender) {
return true;
});
})();

case TSTAPI.kSTOP_SCROLL:
return (async () => {
const currentWindow = TabsStore.getCurrentWindowId();
const windowId = message.window || message.windowId;
if (windowId == 'active') {
const currentWindow = await browser.windows.get(TabsStore.getCurrentWindowId());
if (!currentWindow.focused)
return;
}
else if (windowId != currentWindow) {
return;
}
cancelRunningScroll();
return true;
})();
}
}

Expand Down

0 comments on commit 2d75bc8

Please sign in to comment.