chrisdickinson / raf

requestAnimationFrame polyfill library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Instruction on how to use this in browser

milosdjakonovic opened this issue · comments

This my be considered an issue from perspective of someone who is not nodejs ninja and don't have intentions on using this polyfill in non-browser environment .

What should one do to have browser code built from this?
From what I can see&understand this is for node use.

I have cloned this version locally, and run npm install - which gave me performance-now.

But still I don't get this.

I do care specifically about this polyfill since it is only one I could find that implements callback queueing - fantastic job.

Run it through browserify. http://wzrd.in may help you transition to a build process.

@ljharb Thanks for the response.

But I can confirm that:

https://wzrd.in/standalone/raf@3.3.0
https://wzrd.in/standalone/raf@latest

does not produce code that polyfills requestAnimationFrame.

@milosdjakonovic indeed, the module doesn't polyfill by default. What you want is require('raf/polyfill'), and to have that go through your browserify/webpack build process.

When loading the library via a <script> tag the API is available on window.raf. To automatically polyfill window.requestAnimationFrame and window.cancelAnimationFrame you can invoke window.raf.polyfill(). This is documented here.

I added these instructions to the README. Thanks for bringing this up @milosdjakonovic!