Browse Source

Fix supportsPassive helper function (#439)

Due to missing type annotations, we did not notice that no value was
returned. Thus passive event listeners were always turned off.

Fixing the detection might improve scroll performance on newer browsers.
See https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
Danilo Bargen 7 years ago
parent
commit
69b8de1801
2 changed files with 3 additions and 2 deletions
  1. 2 1
      src/helpers.ts
  2. 1 1
      src/partials/messenger.ts

+ 2 - 1
src/helpers.ts

@@ -232,7 +232,7 @@ export function throttle(fn, threshold: number = 250, scope) {
  *
  * Taken from https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
  */
-export function supportsPassive() {
+export function supportsPassive(): boolean {
     // Test via a getter in the options object to see if the passive property is accessed
     let support = false;
     try {
@@ -241,6 +241,7 @@ export function supportsPassive() {
         });
         window.addEventListener('test', null, opts);
     } catch (e) { /* do nothing */ }
+    return support;
 }
 
 /**

+ 1 - 1
src/partials/messenger.ts

@@ -299,7 +299,7 @@ class ConversationController {
                 $rootScope.$apply(() => {
                     this.updateScrollJump();
                 });
-            }, 100, this), supportsPassive() ? {passive: true} as any : false);
+            }, 100, this), supportsPassive() ? {passive: true} : false);
         }
 
         // Set receiver and type