File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,6 +54,23 @@ impl App {
5454 pos. y /= self . dpr ;
5555 pos
5656 }
57+ #[ cfg( feature = "wasm" ) ]
58+ fn get_delta (
59+ & self ,
60+ mut delta : winit:: event:: MouseScrollDelta ,
61+ ) -> winit:: event:: MouseScrollDelta {
62+ match & mut delta {
63+ winit:: event:: MouseScrollDelta :: LineDelta ( x, y) => {
64+ * x /= self . dpr as f32 ;
65+ * y /= self . dpr as f32 ;
66+ }
67+ winit:: event:: MouseScrollDelta :: PixelDelta ( p) => {
68+ p. x /= self . dpr ;
69+ p. y /= self . dpr ;
70+ }
71+ }
72+ delta
73+ }
5774}
5875#[ cfg( feature = "wasm" ) ]
5976use winit:: platform:: web:: WindowAttributesExtWebSys ;
@@ -233,6 +250,8 @@ impl winit::application::ApplicationHandler for App {
233250 self . input_state . pointer_pos = Some ( rupl:: types:: Vec2 :: new ( position. x , position. y ) ) ;
234251 }
235252 winit:: event:: WindowEvent :: MouseWheel { delta, .. } => {
253+ #[ cfg( feature = "wasm" ) ]
254+ let delta = self . get_delta ( delta) ;
236255 let Some ( s) = self . window ( ) else {
237256 return ;
238257 } ;
You can’t perform that action at this time.
0 commit comments