@@ -40,6 +40,13 @@ export class URDFControls extends GUI {
40
40
this . domElement . style . right = '5px' ;
41
41
this . domElement . setAttribute ( 'class' , 'dg main urdf-gui' ) ;
42
42
43
+ // Add resize functionality
44
+ this . _setupResizeHandling ( {
45
+ minWidth : 150 ,
46
+ grabZoneWidth : 12
47
+ } ) ;
48
+
49
+ // Create folders
43
50
this . _workspaceFolder = this . addFolder ( 'Workspace' ) ;
44
51
this . _workspaceFolder . domElement . setAttribute (
45
52
'class' ,
@@ -207,4 +214,53 @@ export class URDFControls extends GUI {
207
214
}
208
215
return this . controls . joints ;
209
216
}
217
+
218
+ /**
219
+ * Sets up panel resizing functionality
220
+ * @param minWidth - Minimum width of the panel
221
+ * @param maxWidth - Maximum width of the panel
222
+ * @param grabZoneWidth - Width of the area where the mouse can be clicked
223
+ */
224
+ private _setupResizeHandling ( options : {
225
+ minWidth : number ;
226
+ grabZoneWidth : number ;
227
+ } ) : void {
228
+ let isResizing = false ;
229
+ let startX : number ;
230
+ let startWidth : number ;
231
+
232
+ const { minWidth, grabZoneWidth } = options ;
233
+
234
+ const onMouseMove = ( e : MouseEvent ) => {
235
+ if ( ! isResizing ) {
236
+ return ;
237
+ }
238
+
239
+ const width = startWidth - ( e . clientX - startX ) ;
240
+ if ( width >= minWidth ) {
241
+ this . domElement . style . width = `${ width } px` ;
242
+ }
243
+ } ;
244
+
245
+ const onMouseUp = ( ) => {
246
+ isResizing = false ;
247
+ document . removeEventListener ( 'mousemove' , onMouseMove ) ;
248
+ document . removeEventListener ( 'mouseup' , onMouseUp ) ;
249
+ } ;
250
+
251
+ this . domElement . addEventListener ( 'mousedown' , ( e : MouseEvent ) => {
252
+ if (
253
+ e . clientX <
254
+ this . domElement . getBoundingClientRect ( ) . left + grabZoneWidth
255
+ ) {
256
+ isResizing = true ;
257
+ startX = e . clientX ;
258
+ startWidth = parseInt ( getComputedStyle ( this . domElement ) . width , 10 ) ;
259
+ e . preventDefault ( ) ;
260
+
261
+ document . addEventListener ( 'mousemove' , onMouseMove ) ;
262
+ document . addEventListener ( 'mouseup' , onMouseUp ) ;
263
+ }
264
+ } ) ;
265
+ }
210
266
}
0 commit comments