#events #window #channel #js #winit #size #resized

js_resized_event_channel

js resized event channel (only supports full size window)

20 releases

new 0.3.10 Nov 20, 2024
0.3.9 Nov 20, 2024
0.2.0 Nov 18, 2024
0.1.9 Oct 12, 2024

#3 in #event

Download history 544/week @ 2024-10-09 59/week @ 2024-10-16 219/week @ 2024-11-13

219 downloads per month

MIT license

7KB
77 lines

 use js_resized_event_channel::{JsResizeEventChannel, ResizeEventChannel};
 use winit::{dpi::PhysicalSize, event_loop::EventLoop, window::WindowAttributes};

 fn main() {
     let event_loop: EventLoop<()> = EventLoop::new().unwrap();
     let window = event_loop
         .create_window(WindowAttributes::default())
         .unwrap();
     let resize_event_channel = JsResizeEventChannel::init(&window);
     event_loop
         .run(|event, event_loop| {
             if resize_event_channel.try_recv_resized_event() {
                 let _ = window.request_inner_size(resize_event_channel.size());
             }
         })
         .unwrap();
 }

Dependencies

~3–16MB
~241K SLoC