An interesting package, I’ll check it.
For now I’ve finally got it with the next solution:
view =
textarea [getScrollHeight] []
-- Event Handlers
scrollHeightDecoder : Json.Decoder Int
scrollHeightDecoder =
Json.at [ "target", "scrollHeight" ] Json.int
getScrollHeight : Attribute Msg
getScrollHeight =
let
succ height =
Json.succeed (ScrollHeight height)
in
on "keyup" (Json.andThen succ scrollHeightDecoder)
And the equivalent JS code. So, basically elm’s “Html.Events#on” handles a similar “event” object from the code below:
var textarea = document.getElementById("textarea")
textarea.addEventListener("keyup", function (event) {
console.log(event.target.scrollHeight)
}