Remove Canvas when dropped

This commit is contained in:
Héctor Ramón Jiménez 2019-06-25 18:19:22 +02:00
parent b79089ea57
commit 9c5657b86c

View file

@ -17,6 +17,12 @@ pub struct Canvas {
on_mouse_scroll: Option<Closure<dyn FnMut(WheelEvent)>>,
}
impl Drop for Canvas {
fn drop(&mut self) {
self.raw.remove();
}
}
impl Canvas {
pub fn create() -> Result<Self, RootOE> {
let window = web_sys::window().expect("Failed to obtain window");