Created
December 3, 2018 22:12
-
-
Save baldurh/1f4c333f6a287a5b4bf4019d8f123955 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let (left, width) = | |
Webapi.Dom.( | |
switch (Js.toOption(node)) { | |
| Some(element) => | |
switch ( | |
element |> Element.querySelector("[aria-selected=\"true\"]") | |
) { | |
| Some(element) => | |
switch (element |> Element.asHtmlElement) { | |
| Some(element) => ( | |
element |> HtmlElement.offsetLeft, | |
element |> HtmlElement.offsetWidth, | |
) | |
| _ => (0, 0) | |
} | |
| _ => (0, 0) | |
} | |
| _ => (0, 0) | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let (left, width) = | |
Belt.Option.( | |
Webapi.Dom.( | |
Js.toOption(node) | |
->flatMap(Element.querySelector("[aria-selected=\"true\"]")) | |
->flatMap(Element.asHtmlElement) | |
->map(element => | |
( | |
element |> HtmlElement.offsetLeft, | |
element |> HtmlElement.offsetWidth, | |
) | |
) | |
->getWithDefault((0, 0)) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment