@@ -1559,64 +1559,62 @@ let make = (~versions: array<string>) => {
15591559 None
15601560 }, [])
15611561
1562+ let onMouseUp = _ => isDragging .current = false
15621563 let onMouseDown = _ => isDragging .current = true
1564+ let onTouchStart = _ => isDragging .current = true
15631565
1564- let onMove = position => {
1565- if isDragging .current {
1566- switch (
1567- panelRef .current -> Nullable .toOption ,
1568- leftPanelRef .current -> Nullable .toOption ,
1569- rightPanelRef .current -> Nullable .toOption ,
1570- subPanelRef .current -> Nullable .toOption ,
1571- ) {
1572- | (Some (panelElement ), Some (leftElement ), Some (rightElement ), Some (subElement )) =>
1573- let rectPanel = Webapi .Element .getBoundingClientRect (panelElement )
1574-
1575- // Update OutputPanel height
1576- let offsetTop = Webapi .Element .getBoundingClientRect (subElement )["top" ]
1577- Webapi .Element .Style .height (subElement , ` calc(100vh - ${offsetTop-> Float.toString}px)` )
1578-
1579- switch layout {
1580- | Row =>
1581- let delta = Int .toFloat (position ) -. rectPanel ["left" ]
1582-
1583- let leftWidth = delta /. rectPanel ["width" ] *. 100.0
1584- let rightWidth = (rectPanel ["width" ] -. delta ) /. rectPanel ["width" ] *. 100.0
1585-
1586- Webapi .Element .Style .width (leftElement , ` ${leftWidth-> Float.toString}%` )
1587- Webapi .Element .Style .width (rightElement , ` ${rightWidth-> Float.toString}%` )
1588-
1589- | Column =>
1590- let delta = Int .toFloat (position ) -. rectPanel ["top" ]
1591-
1592- let topHeight = delta /. rectPanel ["height" ] *. 100 .
1593- let bottomHeight = (rectPanel ["height" ] -. delta ) /. rectPanel ["height" ] *. 100 .
1594-
1595- Webapi .Element .Style .height (leftElement , ` ${topHeight-> Float.toString}%` )
1596- Webapi .Element .Style .height (rightElement , ` ${bottomHeight-> Float.toString}%` )
1566+ React .useEffect (() => {
1567+ let onMove = position => {
1568+ if isDragging .current {
1569+ switch (
1570+ panelRef .current -> Nullable .toOption ,
1571+ leftPanelRef .current -> Nullable .toOption ,
1572+ rightPanelRef .current -> Nullable .toOption ,
1573+ subPanelRef .current -> Nullable .toOption ,
1574+ ) {
1575+ | (Some (panelElement ), Some (leftElement ), Some (rightElement ), Some (subElement )) =>
1576+ let rectPanel = Webapi .Element .getBoundingClientRect (panelElement )
1577+
1578+ // Update OutputPanel height
1579+ let offsetTop = Webapi .Element .getBoundingClientRect (subElement )["top" ]
1580+ Webapi .Element .Style .height (subElement , ` calc(100vh - ${offsetTop-> Float.toString}px)` )
1581+
1582+ switch layout {
1583+ | Row =>
1584+ let delta = Int .toFloat (position ) -. rectPanel ["left" ]
1585+
1586+ let leftWidth = delta /. rectPanel ["width" ] *. 100.0
1587+ let rightWidth = (rectPanel ["width" ] -. delta ) /. rectPanel ["width" ] *. 100.0
1588+
1589+ Webapi .Element .Style .width (leftElement , ` ${leftWidth-> Float.toString}%` )
1590+ Webapi .Element .Style .width (rightElement , ` ${rightWidth-> Float.toString}%` )
1591+
1592+ | Column =>
1593+ let delta = Int .toFloat (position ) -. rectPanel ["top" ]
1594+
1595+ let topHeight = delta /. rectPanel ["height" ] *. 100 .
1596+ let bottomHeight = (rectPanel ["height" ] -. delta ) /. rectPanel ["height" ] *. 100 .
1597+
1598+ Webapi .Element .Style .height (leftElement , ` ${topHeight-> Float.toString}%` )
1599+ Webapi .Element .Style .height (rightElement , ` ${bottomHeight-> Float.toString}%` )
1600+ }
1601+ | _ => ()
15971602 }
1598- | _ => ()
15991603 }
16001604 }
1601- }
1602-
1603- let onMouseMove = e => {
1604- let position = layout == Row ? ReactEvent .Mouse .clientX (e ) : ReactEvent .Mouse .clientY (e )
1605- onMove (position )
1606- }
1607-
1608- let onMouseUp = _ => isDragging .current = false
16091605
1610- let onTouchMove = e => {
1611- let touches = e -> ReactEvent .Touch .touches
1612- let firstTouch = touches ["0" ]
1613- let position = layout == Row ? firstTouch ["clientX" ] : firstTouch ["clientY" ]
1614- onMove (position )
1615- }
1606+ let onMouseMove = e => {
1607+ let position = layout == Row ? ReactEvent .Mouse .clientX (e ) : ReactEvent .Mouse .clientY (e )
1608+ onMove (position )
1609+ }
16161610
1617- let onTouchStart = _ => isDragging .current = true
1611+ let onTouchMove = e => {
1612+ let touches = e -> ReactEvent .Touch .touches
1613+ let firstTouch = touches ["0" ]
1614+ let position = layout == Row ? firstTouch ["clientX" ] : firstTouch ["clientY" ]
1615+ onMove (position )
1616+ }
16181617
1619- React .useEffect (() => {
16201618 Webapi .Window .addEventListener ("mousemove" , onMouseMove )
16211619 Webapi .Window .addEventListener ("touchmove" , onTouchMove )
16221620 Webapi .Window .addEventListener ("mouseup" , onMouseUp )
@@ -1628,7 +1626,7 @@ let make = (~versions: array<string>) => {
16281626 Webapi .Window .removeEventListener ("mouseup" , onMouseUp )
16291627 },
16301628 )
1631- }, [])
1629+ }, [layout ])
16321630
16331631 let cmErrors = switch compilerState {
16341632 | Ready ({result }) =>
0 commit comments