@colisweb/rescript-toolkit 2.51.1 → 2.51.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -66,24 +66,21 @@ let make = (
|
|
|
66
66
|
let {left, top, width, height} =
|
|
67
67
|
buttonRef->Browser.DomElement.getBoundingClientRect
|
|
68
68
|
let dropdown = ref->Browser.DomElement.getBoundingClientRect
|
|
69
|
-
|
|
70
69
|
let left = left +. width /. 2. -. dropdown.width /. 2.
|
|
71
70
|
|
|
72
|
-
let
|
|
73
|
-
|
|
71
|
+
let adjustmentStyle = ReactDOM.Style.make(
|
|
72
|
+
~top=`${(top +. height)->Js.Float.toString}px`,
|
|
73
|
+
~opacity="1",
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
let adjustmentStyle = switch left {
|
|
77
|
+
| left if left < 0. => adjustmentStyle(~left="8px", ())
|
|
74
78
|
| left if left +. dropdown.width > Browser.innerWidth->Int.toFloat =>
|
|
75
|
-
|
|
76
|
-
| left =>
|
|
79
|
+
adjustmentStyle(~right="8px", ())
|
|
80
|
+
| left => adjustmentStyle(~left=`${left->Js.Float.toString}px`, ())
|
|
77
81
|
}
|
|
78
82
|
|
|
79
|
-
setAdjustmentStyle(_ => Some(
|
|
80
|
-
ReactDOM.Style.make(
|
|
81
|
-
~left,
|
|
82
|
-
~top=`${(top +. height)->Js.Float.toString}px`,
|
|
83
|
-
~opacity="1",
|
|
84
|
-
(),
|
|
85
|
-
),
|
|
86
|
-
))
|
|
83
|
+
setAdjustmentStyle(_ => Some(adjustmentStyle))
|
|
87
84
|
}
|
|
88
85
|
|
|
89
86
|
| _ => ()
|