File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " ecctrl" ,
3
- "version" : " 1.0.49 " ,
3
+ "version" : " 1.0.50 " ,
4
4
"author" : " Erdong Chen" ,
5
5
"license" : " MIT" ,
6
6
"description" : " A floating rigibody character controller for R3F" ,
Original file line number Diff line number Diff line change @@ -97,6 +97,11 @@ const JoystickComponents = (props: EcctrlJoystickProps) => {
97
97
resetJoystick ( )
98
98
}
99
99
100
+ // Reset window size function
101
+ const onWindowResize = ( ) => {
102
+ setWindowSize ( { innerHeight : window . innerHeight , innerWidth : window . innerWidth } )
103
+ }
104
+
100
105
useEffect ( ( ) => {
101
106
const joystickPositionX = joystickDiv . getBoundingClientRect ( ) . x
102
107
const joystickPositionY = joystickDiv . getBoundingClientRect ( ) . y
@@ -111,12 +116,12 @@ const JoystickComponents = (props: EcctrlJoystickProps) => {
111
116
joystickDiv . addEventListener ( "touchmove" , onTouchMove , { passive : false } )
112
117
joystickDiv . addEventListener ( "touchend" , onTouchEnd )
113
118
114
- window . addEventListener ( "resize" , ( ) => { setWindowSize ( { innerHeight : window . innerHeight , innerWidth : window . innerWidth } ) } )
119
+ window . visualViewport . addEventListener ( "resize" , onWindowResize )
115
120
116
121
return ( ) => {
117
122
joystickDiv . removeEventListener ( "touchmove" , onTouchMove )
118
123
joystickDiv . removeEventListener ( "touchend" , onTouchEnd )
119
- window . removeEventListener ( "resize" , ( ) => { } )
124
+ window . visualViewport . removeEventListener ( "resize" , onWindowResize )
120
125
}
121
126
} )
122
127
You can’t perform that action at this time.
0 commit comments