This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhangyang-zerotierone/zeroidc/vendor/wasm-bindgen/guide/src/examples/request-animation-frame.md

27 lines
852 B
Markdown
Raw Normal View History

# `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}}
```