chrisdickinson / raf

requestAnimationFrame polyfill library
MIT License
742 stars 54 forks source link

Instruction on how to use this in browser #33

Closed milosdjakonovic closed 8 years ago

milosdjakonovic commented 8 years ago

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.

ljharb commented 8 years ago

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

milosdjakonovic commented 8 years ago

@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.

ljharb commented 8 years ago

@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.

CMTegner commented 8 years ago

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.

milosdjakonovic commented 8 years ago

@ljharb @CMTegner Worked, thanks.

CMTegner commented 8 years ago

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