Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

send scroll event from webview

ammarahm-ed39e6919c8e5f
diff --git a/apps/mobile/android/app/src/main/assets/index.css b/apps/mobile/android/app/src/main/assets/index.css
index 5cfe73a9f..af443d40b 100644
--- a/apps/mobile/android/app/src/main/assets/index.css
+++ b/apps/mobile/android/app/src/main/assets/index.css
@@ -1,98 +1,103 @@
body {
- margin:0px !important;
- overflow: visible;
+ margin: 0px !important;
+}
+
+.app-main {
+ overflow: visible;
}
#formBox textarea {
- font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
- font-weight: 600 !important;
- background-color: transparent;
- border: none;
- width: 100%;
- outline: none;
- resize: none;
- font-size: 32px;
- }
-
- #formBox {
- margin-block-end: 0px;
- position: relative;
- }
-
- #titlebar {
- background-color: transparent;
- padding-left: 12px;
- padding-right: 12px;
- min-height: 45px;
- display: flex;
- flex-direction: column;
- justify-content: flex-end;
- }
- #formBox > div,
- #formBox > textarea {
- word-wrap: break-word; /* make sure the div and the textarea wrap words in the same way */
- box-sizing: border-box;
- width: 100%;
- }
-
- #formBox > textarea {
- overflow: hidden;
- position: absolute;
- height: 100%;
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
+ Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
+ font-weight: 600 !important;
+ background-color: transparent;
+ border: none;
+ width: 100%;
+ outline: none;
+ resize: none;
+ font-size: 32px;
+}
+
+#formBox {
+ margin-block-end: 0px;
+ position: relative;
+}
+
+#titlebar {
+ background-color: transparent;
+ padding-left: 12px;
+ padding-right: 12px;
+ min-height: 45px;
+ display: flex;
+ flex-direction: column;
+ justify-content: flex-end;
+}
+#formBox > div,
+#formBox > textarea {
+ word-wrap: break-word; /* make sure the div and the textarea wrap words in the same way */
+ box-sizing: border-box;
+ width: 100%;
+}
+
+#formBox > textarea {
+ overflow: hidden;
+ position: absolute;
+ height: 100%;
- padding-top: 4px;
- padding-bottom: 5px;
- }
-
- #textCopy {
- visibility: hidden;
- font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
- font-weight: 600 !important;
- font-size: 32px;
- padding-top: 4px;
- padding-bottom: 5px;
- }
-
- #formBox > div {
- min-height: 45px;
- }
-
- .info-bar {
- color: gray;
- font-size: 11px;
- height: 15px;
- display: flex;
- font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
- padding-left: 4px !important;
- justify-content: space-between;
- }
+ padding-top: 4px;
+ padding-bottom: 5px;
+}
- .info-bar a {
- text-decoration: none;
- color: gray
- }
-
- #titlebar textarea:focus {
- outline: none;
- }
- #infowords {
- margin-right: 5px;
- margin-left: 0px;
- border-radius: 5;
- margin-top: 0;
- }
-
- #infodate {
- margin-right: 5px;
- margin-left: 5px;
- margin-top: 0;
- border-radius: 5;
- }
-
- #infosaved {
- margin-right: 5px;
- margin-left: 5px;
- border-radius: 5;
- margin-top: 0;
- }
+#textCopy {
+ visibility: hidden;
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
+ Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
+ font-weight: 600 !important;
+ font-size: 32px;
+ padding-top: 4px;
+ padding-bottom: 5px;
+}
+#formBox > div {
+ min-height: 45px;
+}
+
+.info-bar {
+ color: gray;
+ font-size: 11px;
+ height: 15px;
+ display: flex;
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
+ Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
+ padding-left: 4px !important;
+ justify-content: space-between;
+}
+
+.info-bar a {
+ text-decoration: none;
+ color: gray;
+}
+
+#titlebar textarea:focus {
+ outline: none;
+}
+#infowords {
+ margin-right: 5px;
+ margin-left: 0px;
+ border-radius: 5;
+ margin-top: 0;
+}
+
+#infodate {
+ margin-right: 5px;
+ margin-left: 5px;
+ margin-top: 0;
+ border-radius: 5;
+}
+
+#infosaved {
+ margin-right: 5px;
+ margin-left: 5px;
+ border-radius: 5;
+ margin-top: 0;
+}
diff --git a/apps/mobile/android/app/src/main/assets/index.html b/apps/mobile/android/app/src/main/assets/index.html
index 857b32f90..df1e28679 100644
--- a/apps/mobile/android/app/src/main/assets/index.html
+++ b/apps/mobile/android/app/src/main/assets/index.html
@@ -8,7 +8,7 @@
</head>
<body>
- <div>
+ <div class="app-main" >
<input id="image-input" accept='image/png, image/gif, image/jpeg, image/bmp, image/x-icon' type="file"
name="name" style="display: none;" />
<div id="titlebar">
diff --git a/apps/mobile/android/app/src/main/assets/listeners.js b/apps/mobile/android/app/src/main/assets/listeners.js
index ef8182aa8..a78bea696 100644
--- a/apps/mobile/android/app/src/main/assets/listeners.js
+++ b/apps/mobile/android/app/src/main/assets/listeners.js
@@ -1,13 +1,29 @@
let titleInput = document.getElementById('titleInput');
let infoBar = '.info-bar';
let info = null;
-
+let scrollTimer = null;
function attachTitleInputListeners() {
infoBar = '.info-bar';
document.addEventListener(
'DOMContentLoaded',
() => {
autosize();
+ document
+ .body.onscroll = (event) => {
+ if (scrollTimer) {
+ clearTimeout(scrollTimer);
+ scrollTimer = null;
+ }
+ scrollTimer = setTimeout(() => {
+ window.ReactNativeWebView.postMessage(
+ JSON.stringify({
+ visible: event.target.documentElement.scrollTop.scrollTop,
+ title: document.getElementById("titleInput").value,
+ type: 'scroll',
+ }),
+ );
+ }, 100);
+ }
},
false,
);
diff --git a/apps/mobile/html/Web.bundle/site/index.html b/apps/mobile/html/Web.bundle/site/index.html
index 26d389c25..df1e28679 100644
--- a/apps/mobile/html/Web.bundle/site/index.html
+++ b/apps/mobile/html/Web.bundle/site/index.html
@@ -1,6 +1,5 @@
<!DOCTYPE html>
<html>
-
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8" />
@@ -9,7 +8,7 @@
</head>
<body>
- <div>
+ <div class="app-main" >
<input id="image-input" accept='image/png, image/gif, image/jpeg, image/bmp, image/x-icon' type="file"
name="name" style="display: none;" />
<div id="titlebar">
diff --git a/apps/mobile/html/Web.bundle/site/listeners.js b/apps/mobile/html/Web.bundle/site/listeners.js
index ef8182aa8..a78bea696 100644
--- a/apps/mobile/html/Web.bundle/site/listeners.js
+++ b/apps/mobile/html/Web.bundle/site/listeners.js
@@ -1,13 +1,29 @@
let titleInput = document.getElementById('titleInput');
let infoBar = '.info-bar';
let info = null;
-
+let scrollTimer = null;
function attachTitleInputListeners() {
infoBar = '.info-bar';
document.addEventListener(
'DOMContentLoaded',
() => {
autosize();
+ document
+ .body.onscroll = (event) => {
+ if (scrollTimer) {
+ clearTimeout(scrollTimer);
+ scrollTimer = null;
+ }
+ scrollTimer = setTimeout(() => {
+ window.ReactNativeWebView.postMessage(
+ JSON.stringify({
+ visible: event.target.documentElement.scrollTop.scrollTop,
+ title: document.getElementById("titleInput").value,
+ type: 'scroll',
+ }),
+ );
+ }, 100);
+ }
},
false,
);