Implement web_sys::Canvas event listeners

This commit is contained in:
Héctor Ramón Jiménez 2019-06-25 18:07:47 +02:00
parent c5703eb00a
commit b79089ea57
9 changed files with 242 additions and 62 deletions

View file

@ -1,11 +1,16 @@
mod canvas;
mod document;
mod event;
mod timeout;
pub use self::canvas::Canvas;
pub use self::document::Document;
pub use self::timeout::Timeout;
use crate::platform::web::WindowExtWebSys;
use crate::window::Window;
use web_sys::HtmlCanvasElement;
pub fn request_animation_frame<F>(f: F)
where
F: Fn(),
@ -15,3 +20,9 @@ where
pub fn throw(msg: &str) {
wasm_bindgen::throw_str(msg);
}
impl WindowExtWebSys for Window {
fn canvas(&self) -> HtmlCanvasElement {
self.window.canvas().raw().clone()
}
}