@@ -205,17 +205,28 @@ export const Repl: Component<ReplProps> = (props) => {
205
205
* Upcomming 2 blocks before the slice of view is used for horizontal and vertical resizers.
206
206
* This first block controls the horizontal resizer.
207
207
*/
208
+ const adjustPercentage = ( percentage : number , lowerBound : number , upperBound : number ) => {
209
+ if ( percentage < lowerBound ) {
210
+ return lowerBound ;
211
+ } else if ( percentage > upperBound ) {
212
+ return upperBound ;
213
+ } else {
214
+ return percentage ;
215
+ }
216
+ } ;
217
+
208
218
const [ horizontalResizer , setHorizontalResizer ] = createSignal < HTMLElement > ( ) ;
209
219
const [ left , setLeft ] = createSignal ( 1.25 ) ;
210
220
211
221
const changeLeft = ( clientX : number , _clientY : number ) => {
212
222
// Adjust the reading according to the width of the resizable panes
213
223
const clientXAdjusted = clientX - horizontalResizer ( ) ! . offsetWidth / 2 ;
214
224
const widthAdjusted = document . body . offsetWidth - horizontalResizer ( ) ! . offsetWidth ;
225
+
215
226
const percentage = clientXAdjusted / ( widthAdjusted / 2 ) ;
216
- if ( percentage < 0.5 || percentage > 1.5 ) return ;
227
+ const percentageAdjusted = adjustPercentage ( percentage , 0.5 , 1.5 ) ;
217
228
218
- setLeft ( percentage ) ;
229
+ setLeft ( percentageAdjusted ) ;
219
230
} ;
220
231
221
232
/**
@@ -240,9 +251,9 @@ export const Repl: Component<ReplProps> = (props) => {
240
251
resultTabs ( ) ! . offsetHeight ;
241
252
242
253
const percentage = clientYAdjusted / ( heightAdjusted / 2 ) ;
243
- if ( percentage < 0.5 || percentage > 1.5 ) return ;
254
+ const percentageAdjusted = adjustPercentage ( percentage , 0.5 , 1.5 ) ;
244
255
245
- setTop ( percentage ) ;
256
+ setTop ( percentageAdjusted ) ;
246
257
} ;
247
258
248
259
return (
0 commit comments