DioxusLabs / DioxusLabs/dioxus
Add support for attaching event listeners to the global window
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
## Feature Request
It's common to want to attach event listeners to the global window. For example, a custom slider element will want to listen to mousedown locally on the slider, but mousemove globally on the window.
Svelte has a [`svelte:window`](https://learn.svelte.dev/tutorial/svelte-window) special element for exactly these use cases.
## Implement Suggestion
Taking a cue from svelte, we could add something like a window special element that events can be attached to:
```rust
rsx! {
dioxus:window {
onmousemove: move |event| handle_mousemove(event)
}
div {
id: "slider",
onmousedown: move |event| handle_mousedown(event),
...
}
}
```
We could also introduce a new `use_window_event` hook or something similar.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.