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

js_resized_event_channel

js resized event channel (only supports full size window)

21 releases

0.3.13 Dec 8, 2024
0.3.10 Nov 20, 2024
0.2.0 Nov 18, 2024
0.1.9 Oct 12, 2024

#7 in #event

Download history 501/week @ 2024-10-08 102/week @ 2024-10-15 165/week @ 2024-11-12 1457/week @ 2024-11-19 3/week @ 2024-11-26 104/week @ 2024-12-03 49/week @ 2024-12-10 8/week @ 2024-12-17 1/week @ 2024-12-24

79 downloads per month
Used in wgpu_starter

MIT license

14KB
69 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–17MB
~249K SLoC