Fix safety check for requestAnimationFrame

Doing `window &&` does not achieve the expected behavior, it instead crashes with an error `ReferenceError: window is not defined`. This fix is simple and necessary for server-side rendering.
pull/85/head
André Staltz 9 years ago committed by Andre Medeiros
parent 946e34cf75
commit 394168f730

@ -1,4 +1,4 @@
var raf = (window && window.requestAnimationFrame) || setTimeout;
var raf = (typeof window !== `undefined` && window.requestAnimationFrame) || setTimeout;
var nextFrame = function(fn) { raf(function() { raf(fn); }); };
function setNextFrame(obj, prop, val) {

@ -1,4 +1,4 @@
var raf = (window && window.requestAnimationFrame) || setTimeout;
var raf = (typeof window !== `undefined` && window.requestAnimationFrame) || setTimeout;
var nextFrame = function(fn) { raf(function() { raf(fn); }); };
function setNextFrame(obj, prop, val) {

Loading…
Cancel
Save