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

js_resized_event_channel

js resized event channel (only supports full size window)

21 releases

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

#5 in #event

Download history 353/week @ 2024-10-06 242/week @ 2024-10-13 8/week @ 2024-10-20 1548/week @ 2024-11-17 77/week @ 2024-11-24

1,625 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
~247K SLoC