File tree Expand file tree Collapse file tree 2 files changed +46
-4
lines changed Expand file tree Collapse file tree 2 files changed +46
-4
lines changed Original file line number Diff line number Diff line change 99 title : "MikaShell Test" ,
1010 backgroundTransparent : true ,
1111 resizable : false ,
12- width : 800 ,
13- height : 500 ,
12+ width : 300 ,
13+ height : 300 ,
1414 } )
1515 . then ( ( ) => {
1616 const params = new URLSearchParams ( window . location . search ) ;
2424 < body >
2525 < h1 > Test open</ h1 >
2626 < p id ="text "> </ p >
27+ < div id ="test-resize "> </ div >
2728 </ body >
29+ < script >
30+ const box = document . getElementById ( "test-resize" ) ;
31+ let count = 0 ;
32+ let direction = 1 ;
33+ setInterval ( ( ) => {
34+ if ( direction === 1 ) {
35+ const item = document . createElement ( "div" ) ;
36+ item . style . width = "100px" ;
37+ item . style . height = "50px" ;
38+ item . style . backgroundColor = "#ff9000" ;
39+ box . appendChild ( item ) ;
40+ count ++ ;
41+ } else {
42+ box . removeChild ( box . lastChild ) ;
43+ count -- ;
44+ }
45+ if ( count === 3 ) {
46+ direction = - 1 ;
47+ } else if ( count === 0 ) {
48+ direction = 1 ;
49+ }
50+ } , 1000 ) ;
51+ let resizing = false ;
52+ new ResizeObserver ( ( ) => {
53+ if ( resizing ) return ;
54+ const style = getComputedStyle ( document . body ) ;
55+ const w =
56+ document . body . scrollWidth +
57+ parseInt ( style . marginLeft ) +
58+ parseInt ( style . marginRight ) ;
59+ const h =
60+ document . body . scrollHeight +
61+ parseInt ( style . marginTop ) +
62+ parseInt ( style . marginBottom ) ;
63+
64+ console . log ( "Resizing to" , w , h ) ;
65+ mikaShell . window . setSize ( w , h ) . then ( ( ) => {
66+ resizing = false ;
67+ } ) ;
68+ } ) . observe ( document . body ) ;
69+ </ script >
2870</ html >
Original file line number Diff line number Diff line change @@ -127,8 +127,8 @@ pub const Window = struct {
127127 if (w .container .window .getResizable () == 1 ) {
128128 return ctx .errors ("setSize is not allowed for resizable window" , .{});
129129 }
130- const width = try ctx .args .integer (1 );
131- const height = try ctx .args .integer (2 );
130+ const width = try ctx .args .integer (0 );
131+ const height = try ctx .args .integer (1 );
132132 w .container .window .setDefaultSize (@intCast (width ), @intCast (height ));
133133 }
134134 pub fn getSize (self : * Self , ctx : * Context ) ! void {
You can’t perform that action at this time.
0 commit comments