3.4.1 • Published 6 years ago

raf v3.4.1

Weekly downloads
5,286,006
License
MIT
Repository
github
Last release
6 years ago

raf

Browser Support

requestAnimationFrame polyfill for node and the browser.

var raf = require('raf')

raf(function tick() {
  // Animation logic
  raf(tick)
})

Note: The stream/event emitter logic found in versions prior to 1.0.0 can be found in raf-stream.

Getting started

CommonJS (Node, Browserify, Webpack, etc.)

Install raf from npm:

npm install --save raf

Require it like you would any other module:

const raf = require('raf')

AMD (require.js, etc)

Download the UMD-bundle from wzrd.in (remember to include the current version number in the filename).

Add it to your AMD module loader config and require it like you would any other module:

define(['raf'], raf => {...})

<script>

Download the UMD-bundle from wzrd.in (remember to include the current version number in the filename).

Then include it via a script tag:

<script src="raf-x.x.x.js"></script>

The API will be available on window.raf.

API

Documentation at Mozilla Developer Network, W3 Specification

var handle = raf(callback)

callback is the function to invoke in the next frame. handle is a long integer value that uniquely identifies the entry in the callback list. This is a non-zero value, but you may not make any other assumptions about its value.

raf.cancel(handle)

handle is the entry identifier returned by raf(). Removes the queued animation frame callback (other queued callbacks will still be invoked unless cancelled).

raf.polyfill(object)

Shorthand to polyfill window.requestAnimationFrame and window.cancelAnimationFrame if necessary (Polyfills global in node).

Alternatively you can require raf/polyfill which will act the same as require('raf').polyfill().

If you provide object the polyfills are attached to that given object, instead of the inferred global. Useful if you have an instance of a fake window object, and want to add raf and caf to it.

Acknowledgments

Based on work by Erik Möller, Paul Irish, and Tino Zijdel (https://gist.github.com/paulirish/1579671)

License

MIT

enzymereact-app-polyfillff-antd-vue@exile_song/vue-components@elliemae/ds-shared@elliemae/ds-utilitiesdcxt-design-xue-xharavan-react-componentsant-mstant-master@devheat/uiplaytwo-core-cms-sections@bushuai/uni-testtaong-grasa@paperlesspost/react-scriptsyzhantdreact-static-jurosh@faizrr/react-ranger@flexis/canvgsitka-webleaf-react-datesrt-time-pickerkolbeinsson88-assignment5kolbeinsson88-stylesactive-react-scriptsseamlessdocs-clientmaicai.m.ddxq.mobibaltimorecounty-react-componentsantd-zp@nebula.ui/engine-ui@rafibarash/react-scriptsamindbootstrap1js-slgorithms-libamindbootstrapnatbootstrap2@luchmewep/mdbreactg2_v587_gv587_adminjdc-rc-commondropdown-multiselectscrollplugintest-rc-commonfind-react@kibalabs/react-static@ironbay/react-scripts-legosuibot-ui-antd@enbock/time-tracker@insync-stageplayer/timedotsbi-react-scripts-tsreact-scripts-jtshuta-btn-demoshuta-img-previewernikita-test-uinikita-test-uip@mygooder/react-scriptsss-ui-lib@cfchase/interactive-landscape@ctrine/jest-settingssignplsignpl-test@deity/falcon-clientreact-to-npm1testzonglicoms@citcfe/cicli-plugin-polyfillp-react-app-polyfill@built/react-scriptsxhn-design-vuezyd-design-vueant-design-vue-xuexueant-design-vue-xxxue-dev-new-xant-design-vue-xxxxue-dev-new2fondfolio-date-pickertmdesign2growth-antd-webant-design-vue-lapreact-xtructreact-dnd-window-scrollinsync-stageplayermarin-stageplayer@kiwipower/time-pickervue-ant-patterns-cicdybbtestui1mehmet-guler-react-gib-libmio-design-vue@trevianxyz/messagecenter-uicria-design-systemtim-react-scriptsreact-beautifull-dnd-scrollzonemtd-react@netty0911/rc-tag@netty0911/rc-menu@netty0911/rc-switch@netty0911/rc-formyusei-modalzarm213213zarm232323@bamboo-design/seaa-tree-select
3.4.1

6 years ago

3.4.0

7 years ago

3.3.2

7 years ago

3.3.1

7 years ago

3.3.0

8 years ago

3.2.0

9 years ago

3.1.0

9 years ago

3.0.0

9 years ago

2.0.4

10 years ago

2.0.3

10 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.2.0

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

11 years ago

0.1.0

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

12 years ago

0.0.0

12 years ago