From d766100c297bc094491de150f24c04719ffa8f4e Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 18 Jan 2018 23:23:56 -0500 Subject: 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 --- app/src/main/assets/js/document_watcher.js | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 app/src/main/assets/js/document_watcher.js (limited to 'app/src/main/assets/js/document_watcher.js') 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 -- cgit v1.2.3