@@ -143,103 +143,178 @@ export function styleDefinition(space: ISpaceDefinition) {
143143 cssElements . push ( `#${ space . id } > .spaces-space-inner { overflow: auto; touch-action: auto; }` ) ;
144144 }
145145
146- let handleOffset = 0 ;
147- const touchHandleSize = space . touchHandleSize / 2 - space . handleSize / 2 ;
146+ let nhandleOffset = 0 ;
147+ const handleSize = `${ space . handleSize } px` ;
148+ const touchHandleSize = `${ space . touchHandleSize / 2 - space . handleSize / 2 } px` ;
148149
149150 switch ( space . handlePlacement ) {
150151 case ResizeHandlePlacement . Inside :
151152 case ResizeHandlePlacement . OverlayInside :
152- handleOffset = space . handleSize ;
153+ nhandleOffset = space . handleSize ;
153154 if ( space . type === Type . Positioned ) {
154- handleOffset = 0 ;
155+ nhandleOffset = 0 ;
155156 }
156157 break ;
157158 case ResizeHandlePlacement . OverlayBoundary :
158- handleOffset = space . handleSize / 2 ;
159+ nhandleOffset = space . handleSize / 2 ;
159160 break ;
160161 }
161162
163+ const handleOffset = `${ nhandleOffset } px` ;
164+
165+ const addCss = ( id : string , pos : { left ?: string ; top ?: string ; right ?: string ; bottom ?: string ; width ?: string ; height ?: string } ) => {
166+ const styles : string [ ] = [ ] ;
167+
168+ if ( pos . left ) styles . push ( `left: ${ pos . left } ` ) ;
169+ if ( pos . top ) styles . push ( `top: ${ pos . top } ` ) ;
170+ if ( pos . right ) styles . push ( `right: ${ pos . right } ` ) ;
171+ if ( pos . bottom ) styles . push ( `bottom: ${ pos . bottom } ` ) ;
172+ if ( pos . width ) styles . push ( `width: ${ pos . width } ` ) ;
173+ if ( pos . height ) styles . push ( `height: ${ pos . height } ` ) ;
174+
175+ cssElements . push ( `#${ space . id } -${ id } { ${ styles . join ( "; " ) } }` ) ;
176+ } ;
177+
162178 if ( space . type === Type . Positioned ) {
163179 if ( space . canResizeLeft ) {
164- cssElements . push (
165- `#${ space . id } -ml { left: calc(${ css ( space . left , true ) } - ${ handleOffset } px); width: ${ space . handleSize } px; top: ${ css (
166- space . top ,
167- ) } ; bottom: ${ css ( space . bottom ) } ; height: ${ css ( space . height ) } ; }`,
168- ) ;
180+ addCss ( "ml" , {
181+ left : `calc(${ css ( space . left , true ) } - ${ handleOffset } )` ,
182+ top : css ( space . top ) ,
183+ bottom : css ( space . bottom ) ,
184+ width : handleSize ,
185+ height : css ( space . height ) ,
186+ } ) ;
169187 }
170188
171189 if ( space . canResizeTop ) {
172- cssElements . push (
173- `#${ space . id } -mt { top: calc(${ css ( space . top , true ) } - ${ handleOffset } px); height: ${ space . handleSize } px; left: ${ css (
174- space . left ,
175- ) } ; right: ${ css ( space . right ) } ; width: ${ css ( space . width ) } ; }`,
176- ) ;
177- cssElements . push (
178- `#${ space . id } -mt:after { top: -${ touchHandleSize } px; bottom: -${ touchHandleSize } px; left: ${ css ( space . left ) } ; right: ${ css (
179- space . right ,
180- ) } ; width: ${ css ( space . width ) } ; }`,
181- ) ;
190+ addCss ( "mt" , {
191+ top : `calc(${ css ( space . top , true ) } - ${ handleOffset } )` ,
192+ left : css ( space . left ) ,
193+ right : css ( space . right ) ,
194+ width : css ( space . width ) ,
195+ height : handleSize ,
196+ } ) ;
197+ addCss ( "mt:after" , {
198+ top : `-${ touchHandleSize } ` ,
199+ bottom : `-${ touchHandleSize } ` ,
200+ left : css ( space . left ) ,
201+ right : css ( space . right ) ,
202+ width : css ( space . width ) ,
203+ } ) ;
182204 }
183205
184206 if ( space . canResizeRight ) {
185207 if ( space . width . size ) {
186- cssElements . push (
187- `# ${ space . id } -mr { left: calc(${ css ( space . left , true ) } + ${ css ( space . width , true ) } - ${
188- space . handleSize
189- } px + ${ handleOffset } px); width: ${ space . handleSize } px; top: ${ css ( space . top ) } ; bottom: ${ css ( space . bottom ) } ; height: ${ css (
190- space . height ,
191- ) } ; }` ,
192- ) ;
208+ addCss ( "mr" , {
209+ left : ` calc(${ css ( space . left , true ) } + ${ css ( space . width , true ) } - ${ handleSize } + ${ handleOffset } )` ,
210+ top : css ( space . top ) ,
211+ bottom : css ( space . bottom ) ,
212+ width : handleSize ,
213+ height : css ( space . height ) ,
214+ } ) ;
193215 } else {
194- cssElements . push (
195- `#${ space . id } -mr { right: calc(${ css ( space . right , true ) } - ${ handleOffset } px); width: ${ space . handleSize } px; top: ${ css (
196- space . top ,
197- ) } ; bottom: ${ css ( space . bottom ) } ; height: ${ css ( space . height ) } ; }`,
198- ) ;
216+ addCss ( "mr" , {
217+ right : `calc(${ css ( space . right , true ) } - ${ handleOffset } )` ,
218+ top : css ( space . top ) ,
219+ bottom : css ( space . bottom ) ,
220+ width : handleSize ,
221+ height : css ( space . height ) ,
222+ } ) ;
199223 }
200- cssElements . push ( `#${ space . id } -mr:after { left: -${ touchHandleSize } px; right: -${ touchHandleSize } px; top: 0; bottom: 0; }` ) ;
224+ addCss ( "mr:after" , {
225+ left : `-${ touchHandleSize } ` ,
226+ right : `-${ touchHandleSize } ` ,
227+ top : `0` ,
228+ bottom : `0` ,
229+ } ) ;
201230 }
202231
203232 if ( space . canResizeBottom ) {
204233 if ( space . height . size ) {
205- cssElements . push (
206- `# ${ space . id } -mb { top: calc(${ css ( space . top , true ) } + ${ css ( space . height , true ) } - ${
207- space . handleSize
208- } px + ${ handleOffset } px); height: ${ space . handleSize } px; left: ${ css ( space . left ) } ; right: ${ css ( space . right ) } ; width: ${ css (
209- space . width ,
210- ) } ; }` ,
211- ) ;
234+ addCss ( "mb" , {
235+ top : ` calc(${ css ( space . top , true ) } + ${ css ( space . height , true ) } - ${ handleSize } + ${ handleOffset } )` ,
236+ left : css ( space . left ) ,
237+ right : css ( space . right ) ,
238+ width : css ( space . width ) ,
239+ height : handleSize ,
240+ } ) ;
212241 } else {
213- cssElements . push (
214- `#${ space . id } -mb { bottom: calc(${ css ( space . bottom , true ) } - ${ handleOffset } px); height: ${ space . handleSize } px; left: ${ css (
215- space . left ,
216- ) } ; right: ${ css ( space . right ) } ; width: ${ css ( space . width ) } ; }`,
217- ) ;
242+ addCss ( "mb" , {
243+ bottom : `calc(${ css ( space . bottom , true ) } - ${ handleOffset } )` ,
244+ left : css ( space . left ) ,
245+ right : css ( space . right ) ,
246+ width : css ( space . width ) ,
247+ height : handleSize ,
248+ } ) ;
218249 }
219- cssElements . push ( `#${ space . id } -mb:after { top: -${ touchHandleSize } px; bottom: -${ touchHandleSize } px; left: 0; right: 0; }` ) ;
250+ addCss ( "mb:after" , {
251+ top : `calc(${ css ( space . left , true ) } - ${ handleOffset } )` ,
252+ bottom : `-${ touchHandleSize } ` ,
253+ left : `0` ,
254+ right : `0` ,
255+ } ) ;
220256 }
221257
222258 if ( space . canResizeTopLeft ) {
223- cssElements . push (
224- `#${ space . id } -mtl { left: calc(${ css ( space . left , true ) } - ${ handleOffset } px); top: ${ css ( space . top ) } ; width: ${
225- space . handleSize
226- } px; height: ${ space . handleSize } px; }`,
227- ) ;
259+ addCss ( "mtl" , {
260+ left : `calc(${ css ( space . left , true ) } - ${ handleOffset } )` ,
261+ top : css ( space . top ) ,
262+ width : handleSize ,
263+ height : handleSize ,
264+ } ) ;
228265 }
229266
230267 if ( space . canResizeTopRight ) {
231268 if ( space . width . size ) {
232- cssElements . push (
233- `#${ space . id } -mtr { left: calc(${ css ( space . left , true ) } + ${ css ( space . width , true ) } - ${
234- space . handleSize
235- } px + ${ handleOffset } px); width: ${ space . handleSize } px; top: ${ css ( space . top ) } ; height: ${ space . handleSize } px; }`,
236- ) ;
269+ addCss ( "mtr" , {
270+ left : `calc(${ css ( space . left , true ) } + ${ css ( space . width , true ) } - ${ handleSize } + ${ handleOffset } ` ,
271+ top : css ( space . top ) ,
272+ width : handleSize ,
273+ height : handleSize ,
274+ } ) ;
275+ } else {
276+ addCss ( "mtr" , {
277+ right : `calc(${ css ( space . right , true ) } - ${ handleOffset } )` ,
278+ top : css ( space . top ) ,
279+ width : handleSize ,
280+ height : handleSize ,
281+ } ) ;
282+ }
283+ }
284+
285+ if ( space . canResizeBottomLeft ) {
286+ if ( space . height . size ) {
287+ addCss ( "mbl" , {
288+ top : `calc(${ css ( space . top , true ) } + ${ css ( space . height , true ) } - ${ handleSize } + ${ handleOffset } )` ,
289+ left : css ( space . left ) ,
290+ width : handleSize ,
291+ height : handleSize ,
292+ } ) ;
293+ } else {
294+ addCss ( "mbl" , {
295+ bottom : `calc(${ css ( space . bottom , true ) } - ${ handleOffset } )` ,
296+ left : css ( space . left ) ,
297+ width : handleSize ,
298+ height : handleSize ,
299+ } ) ;
300+ }
301+ }
302+
303+ if ( space . canResizeBottomRight ) {
304+ if ( space . height . size && space . width . size ) {
305+ addCss ( "mbr" , {
306+ left : `calc(${ css ( space . left , true ) } + ${ css ( space . width , true ) } - ${ handleSize } + ${ handleOffset } ` ,
307+ top : `calc(${ css ( space . top , true ) } + ${ css ( space . height , true ) } - ${ handleSize } + ${ handleOffset } )` ,
308+ width : handleSize ,
309+ height : handleSize ,
310+ } ) ;
237311 } else {
238- cssElements . push (
239- `#${ space . id } -mtr { right: calc(${ css ( space . right , true ) } - ${ handleOffset } px); width: ${ space . handleSize } px; top: ${ css (
240- space . top ,
241- ) } ; height: ${ space . handleSize } px; }`,
242- ) ;
312+ addCss ( "mbr" , {
313+ right : `calc(${ css ( space . right , true ) } - ${ handleOffset } )` ,
314+ bottom : `calc(${ css ( space . bottom , true ) } - ${ handleOffset } )` ,
315+ width : handleSize ,
316+ height : handleSize ,
317+ } ) ;
243318 }
244319 }
245320 } else {
0 commit comments