File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
src/packages/core/components/split-panel Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -222,6 +222,24 @@ export class UmbSplitPanelElement extends LitElement {
222
222
this . #connect( ) ;
223
223
}
224
224
225
+ #onKeydown( event : KeyboardEvent ) {
226
+ if ( event . key === 'ArrowLeft' || event . key === 'ArrowRight' ) {
227
+ const { width } = this . mainElement . getBoundingClientRect ( ) ;
228
+ const divider = this . dividerElement . getBoundingClientRect ( ) ;
229
+
230
+ const dividerPos = divider . left - this . mainElement . getBoundingClientRect ( ) . left ;
231
+ const percentageFromWidth = ( dividerPos / width ) * 100 ;
232
+
233
+ const multiplier = event . shiftKey ? 10 : 1 ;
234
+ const step = 1 * multiplier * ( event . key === 'ArrowLeft' ? - 1 : 1 ) ;
235
+
236
+ const newPercent = percentageFromWidth + step ;
237
+ const toPixels = ( newPercent / 100 ) * this . mainElement . getBoundingClientRect ( ) . width ;
238
+
239
+ this . #setPosition( toPixels ) ;
240
+ }
241
+ }
242
+
225
243
render ( ) {
226
244
return html `
227
245
<div id= "main" >
@@ -230,7 +248,7 @@ export class UmbSplitPanelElement extends LitElement {
230
248
@slotchange = ${ this . #onSlotChanged}
231
249
style= "width: ${ this . _hasStartPanel ? '100%' : '0' } " > </ slot>
232
250
<div id= "divider" >
233
- <div id= "divider-touch-area" tabindex = "0" > </ div>
251
+ <div id= "divider-touch-area" tabindex = "0" @keydown = ${ this . #onKeydown } > </ div>
234
252
</ div>
235
253
<slot name= "end" @slotchange = ${ this . #onSlotChanged} style= "width: ${ this . _hasEndPanel ? '100%' : '0' } " > </ slot>
236
254
</ div>
You can’t perform that action at this time.
0 commit comments