aboutsummaryrefslogtreecommitdiff
path: root/app/src/web
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-11-07 21:16:07 -0800
committerGitHub <noreply@github.com>2020-11-07 21:16:07 -0800
commita6add7ed6b6a58971c5a439b81d6527d3ee196b9 (patch)
tree6de6bbd1da40fad926a15c12958e5ec808ec2367 /app/src/web
parent8cac4ce54358f23a30a762bbb960309914507bb8 (diff)
parentbe1132c6df6ca1a664bc557dd02094b36195cc76 (diff)
downloadfrost-a6add7ed6b6a58971c5a439b81d6527d3ee196b9.tar.gz
frost-a6add7ed6b6a58971c5a439b81d6527d3ee196b9.tar.bz2
frost-a6add7ed6b6a58971c5a439b81d6527d3ee196b9.zip
Merge pull request #1729 from AllanWang/feature-scrolling-aware
Diffstat (limited to 'app/src/web')
-rw-r--r--app/src/web/ts/context_a.ts8
-rw-r--r--app/src/web/ts/scroll_stop.ts25
-rw-r--r--app/src/web/typings/frost.d.ts4
3 files changed, 37 insertions, 0 deletions
diff --git a/app/src/web/ts/context_a.ts b/app/src/web/ts/context_a.ts
index 9faa1e94..ad81279e 100644
--- a/app/src/web/ts/context_a.ts
+++ b/app/src/web/ts/context_a.ts
@@ -110,6 +110,14 @@
Frost.longClick(true);
longClick = true;
+ /**
+ * Don't handle context events while scrolling
+ */
+ if (Frost.isScrolling()) {
+ console.log("Skip from scrolling");
+ return;
+ }
+
/*
* Commonality; check for valid target
*/
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
diff --git a/app/src/web/typings/frost.d.ts b/app/src/web/typings/frost.d.ts
index ae7c97ab..9f77ce9e 100644
--- a/app/src/web/typings/frost.d.ts
+++ b/app/src/web/typings/frost.d.ts
@@ -24,6 +24,10 @@ declare interface FrostJSI {
handleHeader(html: string | null)
allowHorizontalScrolling(enable: boolean)
+
+ setScrolling(scrolling: boolean)
+
+ isScrolling(): boolean
}
declare var Frost: FrostJSI;