mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Fix ResizeTask drop (#915)
This commit is contained in:
parent
3dca0c7758
commit
ee4792c7f6
@ -54,11 +54,9 @@ impl ResizeService {
|
|||||||
callback.emit(dimensions);
|
callback.emit(dimensions);
|
||||||
};
|
};
|
||||||
let handle = js! {
|
let handle = js! {
|
||||||
var callback = @{callback};
|
var handle = @{callback};
|
||||||
var action = function() {
|
window.addEventListener("resize", handle);
|
||||||
callback();
|
return handle;
|
||||||
};
|
|
||||||
return window.addEventListener("resize", action);
|
|
||||||
};
|
};
|
||||||
ResizeTask(Some(handle))
|
ResizeTask(Some(handle))
|
||||||
}
|
}
|
||||||
@ -70,7 +68,7 @@ impl Drop for ResizeTask {
|
|||||||
js! {
|
js! {
|
||||||
@(no_return)
|
@(no_return)
|
||||||
var handle = @{handle};
|
var handle = @{handle};
|
||||||
handle.callback.drop();
|
window.removeEventListener("resize", handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user