@samitouri / QOS-React-2 / commits / 4c97ffee34
Fork 0

The library for web and native user interfaces.

Bring in Facebook's requestAnimationFrame module

Paul O’Shannessy committed Jun 20, 2013 at 16:51 UTC 4c97ffee348ada09749a262a7ca22a7853551225
1 file changed +37
src/vendor/core/requestAnimationFrame.js new
+37
@@ -0,0 +1,37 @@
1 +/**
2 + * Copyright 2013 Facebook, Inc.
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + *
16 + * @providesModule requestAnimationFrame
17 + */
18 +
19 +var emptyFunction = require('emptyFunction');
20 +
21 +var requestAnimationFrame =
22 + window.requestAnimationFrame ||
23 + window.webkitRequestAnimationFrame ||
24 + window.mozRequestAnimationFrame ||
25 + window.oRequestAnimationFrame ||
26 + window.msRequestAnimationFrame ||
27 + function(callback) {
28 + // Browsers which don't support requestAnimationFrame are likely running on
29 + // older hardware, so it's not reasonable to expect 60FPS animations out of
30 + // them. 30FPS (33.3ms per frame) is more reasonable.
31 + return window.setTimeout(callback, 33);
32 + };
33 +
34 +// Works around a rare bug in Safari 6 where the first request is never invoked.
35 +requestAnimationFrame(emptyFunction);
36 +
37 +module.exports = requestAnimationFrame;