1
- import React from 'react' ;
1
+ import React , { useState , useEffect } from 'react' ;
2
2
import { Tooltip } from 'react-tooltip'
3
3
import { renderToStaticMarkup } from 'react-dom/server' ;
4
4
const _ = require ( 'lodash' ) ;
@@ -8,7 +8,7 @@ const Runtime = ({
8
8
setOpenScenarioID,
9
9
reloadScenarios,
10
10
handleClickScenarioToActive, handleClickNewScenario,
11
- handleClickStartStop, logArgs, duplicateScenario
11
+ handleClickStartStop, logArgs, duplicateScenario, scenarioListHeight , setScenarioListHeight
12
12
} ) => {
13
13
14
14
const visibleTooltipProperties = [
@@ -121,27 +121,39 @@ const Runtime = ({
121
121
return < div />
122
122
}
123
123
124
- const resizableDiv = document . getElementById ( "resizableDiv" ) ;
124
+ useEffect ( ( ) => {
125
+ if ( scenarioListHeight ) {
126
+ const resizableDiv = document . getElementById ( "resizableDiv" ) ;
127
+ resizableDiv . style . height = scenarioListHeight ;
128
+ }
129
+ } ) ;
125
130
126
131
let mousePosition ;
127
132
const resize = ( e ) => {
133
+ if ( e . buttons === 0 ) {
134
+ // No mouse button is pressed, release event listener
135
+ document . body . style = "user-select: auto;"
136
+ document . removeEventListener ( "mousemove" , resize , false ) ;
137
+ }
128
138
const yDimension = mousePosition - e . y ;
129
139
mousePosition = e . y ;
130
- resizableDiv . style . height = ( parseInt ( getComputedStyle ( resizableDiv , '' ) . height ) - yDimension ) + "px" ;
140
+ const resizableDiv = document . getElementById ( "resizableDiv" ) ;
141
+
142
+ const newHeight = ( parseInt ( getComputedStyle ( resizableDiv , '' ) . height ) - yDimension ) + "px" ;
143
+ resizableDiv . style . height = newHeight ;
144
+ setScenarioListHeight ( newHeight ) ;
131
145
}
132
146
133
147
const onMouseDown = ( e ) => {
134
148
if ( e . pageY > ( e . target . offsetTop + e . target . offsetHeight ) ) {
135
149
mousePosition = e . y ;
150
+ document . body . style = "user-select: none;"
136
151
document . addEventListener ( "mousemove" , resize , false ) ;
137
152
}
138
153
}
139
154
140
155
const onMouseUp = ( ) => {
141
- document . removeEventListener ( "mousemove" , resize , false ) ;
142
- }
143
-
144
- const onMouseOut = ( ) => {
156
+ document . body . style = "user-select: auto;"
145
157
document . removeEventListener ( "mousemove" , resize , false ) ;
146
158
}
147
159
@@ -165,7 +177,7 @@ const Runtime = ({
165
177
166
178
< div className = "Runtime__scenarios-controls" id = "resizableDiv" >
167
179
< div className = "Runtime__scenarios-heading" > Ladatut skenaariot</ div >
168
- < div className = "Runtime__scenarios" >
180
+ < div className = "Runtime__scenarios" id = "scenarioList" >
169
181
{ /* Create table of all scenarios "<Button-To-Add-As-Runnable> <Button-To-Open-Configuration>" */ }
170
182
{ scenarios . map ( ( s ) => {
171
183
// Component for the tooltip showing scenario settings
@@ -234,7 +246,7 @@ const Runtime = ({
234
246
< div className = { "Runtime__scenario-delete" }
235
247
onClick = { ( e ) => runningScenarioID ? undefined : deleteScenario ( s ) }
236
248
> </ div >
237
- < Tooltip id = "scenario-tooltip" style = { { borderRadius : "1rem" , maxWidth : "40rem" , marginLeft : "-50px" } } />
249
+ < Tooltip id = "scenario-tooltip" style = { { borderRadius : "1rem" , maxWidth : "40rem" , marginLeft : "-50px" , zIndex : 2 } } />
238
250
239
251
240
252
< div className = { "Runtime__scenario-clone" }
@@ -256,7 +268,7 @@ const Runtime = ({
256
268
</ button >
257
269
</ div >
258
270
</ div >
259
- < div className = "Runtime__scenarios_controls_drag_handle" onMouseDown = { onMouseDown } onMouseUp = { onMouseUp } onMouseOut = { onMouseOut } />
271
+ < div className = "Runtime__scenarios_controls_drag_handle" onMouseDown = { onMouseDown } onMouseUp = { onMouseUp } />
260
272
261
273
< div className = "Runtime__start-stop-controls" >
262
274
< div className = "Runtime__heading" > Ajettavana</ div >
0 commit comments