@@ -1559,64 +1559,62 @@ let make = (~versions: array<string>) => {
1559
1559
None
1560
1560
}, [])
1561
1561
1562
+ let onMouseUp = _ => isDragging .current = false
1562
1563
let onMouseDown = _ => isDragging .current = true
1564
+ let onTouchStart = _ => isDragging .current = true
1563
1565
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
+ | _ => ()
1597
1602
}
1598
- | _ => ()
1599
1603
}
1600
1604
}
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
1609
1605
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
+ }
1616
1610
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
+ }
1618
1617
1619
- React .useEffect (() => {
1620
1618
Webapi .Window .addEventListener ("mousemove" , onMouseMove )
1621
1619
Webapi .Window .addEventListener ("touchmove" , onTouchMove )
1622
1620
Webapi .Window .addEventListener ("mouseup" , onMouseUp )
@@ -1628,7 +1626,7 @@ let make = (~versions: array<string>) => {
1628
1626
Webapi .Window .removeEventListener ("mouseup" , onMouseUp )
1629
1627
},
1630
1628
)
1631
- }, [])
1629
+ }, [layout ])
1632
1630
1633
1631
let cmErrors = switch compilerState {
1634
1632
| Ready ({result }) =>
0 commit comments