diff options
author | Allan Wang <me@allanwang.ca> | 2020-11-07 20:19:22 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2020-11-07 20:19:22 -0800 |
commit | f35a33b5c49c4dc768c1be8ddf3393f79acaa57f (patch) | |
tree | a7c55efe958144ef9a3a064132e4a16e38714e5d /app/src/web/ts/scroll_stop.ts | |
parent | 8cac4ce54358f23a30a762bbb960309914507bb8 (diff) | |
download | frost-f35a33b5c49c4dc768c1be8ddf3393f79acaa57f.tar.gz frost-f35a33b5c49c4dc768c1be8ddf3393f79acaa57f.tar.bz2 frost-f35a33b5c49c4dc768c1be8ddf3393f79acaa57f.zip |
Disable context menu shortly after scrolling
Diffstat (limited to 'app/src/web/ts/scroll_stop.ts')
-rw-r--r-- | app/src/web/ts/scroll_stop.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/src/web/ts/scroll_stop.ts b/app/src/web/ts/scroll_stop.ts new file mode 100644 index 00000000..1ec6d30b --- /dev/null +++ b/app/src/web/ts/scroll_stop.ts @@ -0,0 +1,25 @@ +// Listen when scrolling events stop +(function () { + let scrollTimeout: number | undefined = undefined; + let scrolling: boolean = false; + + window.addEventListener('scroll', function (event) { + + if (!scrolling) { + Frost.setScrolling(true); + scrolling = true; + } + + window.clearTimeout(scrollTimeout); + + scrollTimeout = setTimeout(function () { + if (scrolling) { + Frost.setScrolling(false); + scrolling = false; + } + }, 600); + // For our specific use case, we want to release other features pretty far after scrolling stops + // For general scrolling use cases, the delta can be much smaller + // My assumption for context menus is that the long press is 500ms + }, false); +}).call(undefined);
\ No newline at end of file |