Browse Source

fix rAF wrapper so it returns id so that it can be cancelled

Gregg Tavares 7 years ago
parent
commit
49f846d364
1 changed files with 2 additions and 6 deletions
  1. 2 6
      threejs/resources/threejs-lessons-helper.js

+ 2 - 6
threejs/resources/threejs-lessons-helper.js

@@ -301,13 +301,9 @@
 
       return function(callback, element) {
         const handler = function() {
-          if (isOnScreen(element)) {
-            oldRAF(callback, element);
-          } else {
-            oldRAF(handler, element);
-          }
+          return oldRAF(isOnScreen(element) ? callback : handler, element);
         };
-        handler();
+        return handler();
       };
 
     }(topWindow.requestAnimationFrame));