{-# LANGUAGE OverloadedStrings #-}
module Miso.Native.X.Element.ScrollCoordinator.Event
(
onOffset
, onOffsetWith
, onOffsetMain
, onOffsetMainWith
, ScrollCoordinatorOffsetEvent (..)
, offsetDecoder
, scrollCoordinatorEvents
) where
import qualified Data.Map as M
import Miso.Event
import Miso.JSON
import Miso.Types (Attribute, EventHandler, DOMRef)
scrollCoordinatorEvents :: Events
scrollCoordinatorEvents :: Events
scrollCoordinatorEvents = [(MisoString, Phase)] -> Events
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [ (MisoString
"offset", Phase
BUBBLE) ]
data ScrollCoordinatorOffsetEvent
= ScrollCoordinatorOffsetEvent
{ ScrollCoordinatorOffsetEvent -> Double
height :: Double
, ScrollCoordinatorOffsetEvent -> Double
offset :: Double
} deriving (Int -> ScrollCoordinatorOffsetEvent -> ShowS
[ScrollCoordinatorOffsetEvent] -> ShowS
ScrollCoordinatorOffsetEvent -> String
(Int -> ScrollCoordinatorOffsetEvent -> ShowS)
-> (ScrollCoordinatorOffsetEvent -> String)
-> ([ScrollCoordinatorOffsetEvent] -> ShowS)
-> Show ScrollCoordinatorOffsetEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScrollCoordinatorOffsetEvent -> ShowS
showsPrec :: Int -> ScrollCoordinatorOffsetEvent -> ShowS
$cshow :: ScrollCoordinatorOffsetEvent -> String
show :: ScrollCoordinatorOffsetEvent -> String
$cshowList :: [ScrollCoordinatorOffsetEvent] -> ShowS
showList :: [ScrollCoordinatorOffsetEvent] -> ShowS
Show, ScrollCoordinatorOffsetEvent
-> ScrollCoordinatorOffsetEvent -> Bool
(ScrollCoordinatorOffsetEvent
-> ScrollCoordinatorOffsetEvent -> Bool)
-> (ScrollCoordinatorOffsetEvent
-> ScrollCoordinatorOffsetEvent -> Bool)
-> Eq ScrollCoordinatorOffsetEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScrollCoordinatorOffsetEvent
-> ScrollCoordinatorOffsetEvent -> Bool
== :: ScrollCoordinatorOffsetEvent
-> ScrollCoordinatorOffsetEvent -> Bool
$c/= :: ScrollCoordinatorOffsetEvent
-> ScrollCoordinatorOffsetEvent -> Bool
/= :: ScrollCoordinatorOffsetEvent
-> ScrollCoordinatorOffsetEvent -> Bool
Eq)
offsetDecoder :: Decoder ScrollCoordinatorOffsetEvent
offsetDecoder :: Decoder ScrollCoordinatorOffsetEvent
offsetDecoder = [MisoString
"detail"] [MisoString]
-> (Value -> Parser ScrollCoordinatorOffsetEvent)
-> Decoder ScrollCoordinatorOffsetEvent
forall a. [MisoString] -> (Value -> Parser a) -> Decoder a
`at` Value -> Parser ScrollCoordinatorOffsetEvent
details
where
details :: Value -> Parser ScrollCoordinatorOffsetEvent
details = MisoString
-> (Object -> Parser ScrollCoordinatorOffsetEvent)
-> Value
-> Parser ScrollCoordinatorOffsetEvent
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"detail" ((Object -> Parser ScrollCoordinatorOffsetEvent)
-> Value -> Parser ScrollCoordinatorOffsetEvent)
-> (Object -> Parser ScrollCoordinatorOffsetEvent)
-> Value
-> Parser ScrollCoordinatorOffsetEvent
forall a b. (a -> b) -> a -> b
$ \Object
o ->
Double -> Double -> ScrollCoordinatorOffsetEvent
ScrollCoordinatorOffsetEvent
(Double -> Double -> ScrollCoordinatorOffsetEvent)
-> Parser Double -> Parser (Double -> ScrollCoordinatorOffsetEvent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> MisoString -> Parser Double
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"height"
Parser (Double -> ScrollCoordinatorOffsetEvent)
-> Parser Double -> Parser ScrollCoordinatorOffsetEvent
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> MisoString -> Parser Double
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"offset"
onOffset :: (ScrollCoordinatorOffsetEvent -> action) -> Attribute model action
onOffset :: forall action model.
(ScrollCoordinatorOffsetEvent -> action) -> Attribute model action
onOffset ScrollCoordinatorOffsetEvent -> action
action = MisoString
-> Decoder ScrollCoordinatorOffsetEvent
-> (ScrollCoordinatorOffsetEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"offset" Decoder ScrollCoordinatorOffsetEvent
offsetDecoder (\ScrollCoordinatorOffsetEvent
e model
_ DOMRef
_ -> ScrollCoordinatorOffsetEvent -> action
action ScrollCoordinatorOffsetEvent
e)
onOffsetMain :: (ScrollCoordinatorOffsetEvent -> action) -> EventHandler model action
onOffsetMain :: forall action model.
(ScrollCoordinatorOffsetEvent -> action)
-> EventHandler model action
onOffsetMain ScrollCoordinatorOffsetEvent -> action
action = MisoString
-> Decoder ScrollCoordinatorOffsetEvent
-> (ScrollCoordinatorOffsetEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"offset" Decoder ScrollCoordinatorOffsetEvent
offsetDecoder (\ScrollCoordinatorOffsetEvent
e model
_ DOMRef
_ -> ScrollCoordinatorOffsetEvent -> action
action ScrollCoordinatorOffsetEvent
e)
onOffsetMainWith :: (ScrollCoordinatorOffsetEvent -> model -> DOMRef -> action) -> EventHandler model action
onOffsetMainWith :: forall model action.
(ScrollCoordinatorOffsetEvent -> model -> DOMRef -> action)
-> EventHandler model action
onOffsetMainWith ScrollCoordinatorOffsetEvent -> model -> DOMRef -> action
action = MisoString
-> Decoder ScrollCoordinatorOffsetEvent
-> (ScrollCoordinatorOffsetEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"offset" Decoder ScrollCoordinatorOffsetEvent
offsetDecoder ScrollCoordinatorOffsetEvent -> model -> DOMRef -> action
action
onOffsetWith :: (ScrollCoordinatorOffsetEvent -> DOMRef -> action) -> Attribute model action
onOffsetWith :: forall action model.
(ScrollCoordinatorOffsetEvent -> DOMRef -> action)
-> Attribute model action
onOffsetWith ScrollCoordinatorOffsetEvent -> DOMRef -> action
action = MisoString
-> Decoder ScrollCoordinatorOffsetEvent
-> (ScrollCoordinatorOffsetEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"offset" Decoder ScrollCoordinatorOffsetEvent
offsetDecoder ((ScrollCoordinatorOffsetEvent -> model -> DOMRef -> action)
-> Attribute model action)
-> (ScrollCoordinatorOffsetEvent -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \ScrollCoordinatorOffsetEvent
v model
_ DOMRef
domRef -> ScrollCoordinatorOffsetEvent -> DOMRef -> action
action ScrollCoordinatorOffsetEvent
v DOMRef
domRef