aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/assets/js
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-01-18 23:23:56 -0500
committerAllan Wang <me@allanwang.ca>2018-01-20 16:42:37 -0500
commitd766100c297bc094491de150f24c04719ffa8f4e (patch)
treeb69863dace2fcb45d5fd25c276ca450e07305c44 /app/src/main/assets/js
parent78b3cc41e4c9f8d141ad46ee75e476fa2d177f19 (diff)
downloadfrost-d766100c297bc094491de150f24c04719ffa8f4e.tar.gz
frost-d766100c297bc094491de150f24c04719ffa8f4e.tar.bz2
frost-d766100c297bc094491de150f24c04719ffa8f4e.zip
Enhancement/speed up (#650)
* Revert back to m.facebook * Add initial speedup * Update theme * Fix link press for event status * Move web states to fb const * Fix images and email * Fix up flyweight for requests * Ensure frost request is synchronous * Prepare diff utils * Improve speed and fix blank overlay * Update comments * Add debugger and fix searchview * Theme discover pages. Resolves #654 * Fix duplicate reload * Fix image loading * Update changelog * Update tests * Rename test Update dependencies Update gitignore
Diffstat (limited to 'app/src/main/assets/js')
-rw-r--r--app/src/main/assets/js/document_watcher.coffee24
-rw-r--r--app/src/main/assets/js/document_watcher.js38
-rw-r--r--app/src/main/assets/js/menu.coffee2
-rw-r--r--app/src/main/assets/js/menu.js2
4 files changed, 64 insertions, 2 deletions
diff --git a/app/src/main/assets/js/document_watcher.coffee b/app/src/main/assets/js/document_watcher.coffee
new file mode 100644
index 00000000..11cf7d53
--- /dev/null
+++ b/app/src/main/assets/js/document_watcher.coffee
@@ -0,0 +1,24 @@
+# emit key once half the viewport is covered
+
+isReady = ->
+ if not (document?.body?)
+ return false
+ return document.body.scrollHeight > innerHeight + 100
+
+if isReady()
+ console.log("Already ready")
+ Frost?.isReady()
+ return
+
+console.log("Injected document watcher")
+
+observer = new MutationObserver(() ->
+ if isReady()
+ observer.disconnect()
+ Frost?.isReady()
+ console.log("Documented surpassed height in #{performance.now()}")
+)
+
+observer.observe document,
+ childList: true
+ subtree: true \ No newline at end of file
diff --git a/app/src/main/assets/js/document_watcher.js b/app/src/main/assets/js/document_watcher.js
new file mode 100644
index 00000000..4613dc87
--- /dev/null
+++ b/app/src/main/assets/js/document_watcher.js
@@ -0,0 +1,38 @@
+"use strict";
+
+(function () {
+ // emit key once half the viewport is covered
+ var isReady, observer;
+
+ isReady = function isReady() {
+ if (!((typeof document !== "undefined" && document !== null ? document.body : void 0) != null)) {
+ return false;
+ }
+ return document.body.scrollHeight > innerHeight + 100;
+ };
+
+ if (isReady()) {
+ console.log("Already ready");
+ if (typeof Frost !== "undefined" && Frost !== null) {
+ Frost.isReady();
+ }
+ return;
+ }
+
+ console.log("Injected document watcher");
+
+ observer = new MutationObserver(function () {
+ if (isReady()) {
+ observer.disconnect();
+ if (typeof Frost !== "undefined" && Frost !== null) {
+ Frost.isReady();
+ }
+ return console.log("Documented surpassed height in " + performance.now());
+ }
+ });
+
+ observer.observe(document, {
+ childList: true,
+ subtree: true
+ });
+}).call(undefined); \ No newline at end of file
diff --git a/app/src/main/assets/js/menu.coffee b/app/src/main/assets/js/menu.coffee
index 8072eeab..384496f7 100644
--- a/app/src/main/assets/js/menu.coffee
+++ b/app/src/main/assets/js/menu.coffee
@@ -12,7 +12,7 @@ y = new MutationObserver((mutations) ->
)
y.observe viewport, attributes: true
y.observe root, attributes: true
-x = new MutationObserver((mutations) ->
+x = new MutationObserver(() ->
menu = document.querySelector(".mSideMenu")
if menu != null
x.disconnect()
diff --git a/app/src/main/assets/js/menu.js b/app/src/main/assets/js/menu.js
index 49534c7e..bfdca4a3 100644
--- a/app/src/main/assets/js/menu.js
+++ b/app/src/main/assets/js/menu.js
@@ -29,7 +29,7 @@
attributes: true
});
- x = new MutationObserver(function (mutations) {
+ x = new MutationObserver(function () {
var menu;
menu = document.querySelector(".mSideMenu");
if (menu !== null) {