Skip to content

Commit

Permalink
Add UI.Sizing.fromPx and Lib.ScrollEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
hojberg committed Jul 27, 2023
1 parent c4d90d1 commit 028f29a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/Lib/ScrollEvent.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module Lib.ScrollEvent exposing (..)

import Json.Decode as Decode exposing (int)
import Json.Decode.Pipeline exposing (requiredAt)


type alias ScrollEvent =
{ scrollHeight : Int
, scrollLeft : Int
, scrollTop : Int
, scrollWidth : Int
, clientHeight : Int
, clientLeft : Int
, clientTop : Int
, clientWidth : Int
}


decode : Decode.Decoder ScrollEvent
decode =
Decode.succeed ScrollEvent
|> requiredAt [ "currentTarget", "scrollHeight" ] int
|> requiredAt [ "currentTarget", "scrollLeft" ] int
|> requiredAt [ "currentTarget", "scrollTop" ] int
|> requiredAt [ "currentTarget", "scrollWidth" ] int
|> requiredAt [ "currentTarget", "clientHeight" ] int
|> requiredAt [ "currentTarget", "clientLeft" ] int
|> requiredAt [ "currentTarget", "clientTop" ] int
|> requiredAt [ "currentTarget", "clientWidth" ] int


decodeToMsg : (ScrollEvent -> msg) -> Decode.Decoder msg
decodeToMsg toMsg =
Decode.map toMsg decode

0 comments on commit 028f29a

Please sign in to comment.