Skip to content

Commit

Permalink
fix(raf): test for undefined raf
Browse files Browse the repository at this point in the history
When in a headless environment RAF may not be defined so we need to return the polyfilled version rather than letting the undefined function be called.
  • Loading branch information
Barryrowe authored and adamdbradley committed May 18, 2016
1 parent daa4ccc commit 1c16008
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ionic/util/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
})();

// use native raf rather than the zone wrapped one
export const nativeRaf = (window[window['Zone']['__symbol__']('requestAnimationFrame')] || window[window['Zone']['__symbol__']('webkitRequestAnimationFrame')])['bind'](window);
let originalRaf = (window[window['Zone']['__symbol__']('requestAnimationFrame')] || window[window['Zone']['__symbol__']('webkitRequestAnimationFrame')]);
// if the originalRaf from the Zone symbol is not available, we need to provide the polyfilled version
export const nativeRaf = originalRaf !== undefined ? originalRaf['bind'](window) : window.requestAnimationFrame.bind(window);

// zone wrapped raf
export const raf = window.requestAnimationFrame.bind(window);
Expand Down

0 comments on commit 1c16008

Please sign in to comment.