mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-22 09:11:35 +00:00
examples: Add a requestAnimationFrame loop example
This commit is contained in:
@ -25,6 +25,7 @@
|
||||
- [web-sys: `canvas` Julia set](./examples/julia.md)
|
||||
- [web-sys: WebAudio](./examples/web-audio.md)
|
||||
- [web-sys: WebGL](./examples/webgl.md)
|
||||
- [web-sys: `requestAnimationFrame`](./examples/request-animation-frame.md)
|
||||
- [web-sys: A Simple Paint Program](./examples/paint.md)
|
||||
- [Parallel Raytracing](./examples/raytrace.md)
|
||||
- [web-sys: A TODO MVC App](./examples/todomvc.md)
|
||||
|
26
guide/src/examples/request-animation-frame.md
Normal file
26
guide/src/examples/request-animation-frame.md
Normal file
@ -0,0 +1,26 @@
|
||||
# `web-sys`: A `requestAnimationFrame` Loop
|
||||
|
||||
[View full source code][code] or [view the compiled example online][online]
|
||||
|
||||
[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/request-animation-frame/
|
||||
[code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/request-animation-frame
|
||||
|
||||
This is an example of a `requestAnimationFrame` loop using the `web-sys` crate!
|
||||
It renders a count of how many times a `requestAnimationFrame` callback has been
|
||||
invoked and then it breaks out of the `requestAnimationFrame` loop after 300
|
||||
iterations.
|
||||
|
||||
## `Cargo.toml`
|
||||
|
||||
You can see here how we depend on `web-sys` and activate associated features to
|
||||
enable all the various APIs:
|
||||
|
||||
```toml
|
||||
{{#include ../../../examples/request-animation-frame/Cargo.toml}}
|
||||
```
|
||||
|
||||
## `src/lib.rs`
|
||||
|
||||
```rust
|
||||
{{#include ../../../examples/request-animation-frame/src/lib.rs}}
|
||||
```
|
Reference in New Issue
Block a user