{-# LANGUAGE OverloadedStrings #-}
module Miso.Native.X.Element.Viewpager.Event
(
onChange
, onChangeWith
, onChangeMain
, onChangeMainWith
, onOffsetChange
, onOffsetChangeWith
, onOffsetChangeMain
, onOffsetChangeMainWith
, onWillChange
, onWillChangeWith
, onWillChangeMain
, onWillChangeMainWith
, ViewpagerChangeEvent (..)
, viewpagerChangeDecoder
, offsetChangeDecoder
, viewpagerEvents
) where
import qualified Data.Map as M
import Miso.Event
import Miso.JSON
import Miso.Types (DOMRef, Attribute, EventHandler)
viewpagerEvents :: Events
= [(MisoString, Phase)] -> Events
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList
[ (MisoString
"change", Phase
BUBBLE)
, (MisoString
"offsetchange", Phase
BUBBLE)
, (MisoString
"willchange", Phase
BUBBLE)
]
data
=
{ ViewpagerChangeEvent -> Int
index :: Int
, ViewpagerChangeEvent -> Bool
isDragged :: Bool
} deriving (Int -> ViewpagerChangeEvent -> ShowS
[ViewpagerChangeEvent] -> ShowS
ViewpagerChangeEvent -> String
(Int -> ViewpagerChangeEvent -> ShowS)
-> (ViewpagerChangeEvent -> String)
-> ([ViewpagerChangeEvent] -> ShowS)
-> Show ViewpagerChangeEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ViewpagerChangeEvent -> ShowS
showsPrec :: Int -> ViewpagerChangeEvent -> ShowS
$cshow :: ViewpagerChangeEvent -> String
show :: ViewpagerChangeEvent -> String
$cshowList :: [ViewpagerChangeEvent] -> ShowS
showList :: [ViewpagerChangeEvent] -> ShowS
Show, ViewpagerChangeEvent -> ViewpagerChangeEvent -> Bool
(ViewpagerChangeEvent -> ViewpagerChangeEvent -> Bool)
-> (ViewpagerChangeEvent -> ViewpagerChangeEvent -> Bool)
-> Eq ViewpagerChangeEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ViewpagerChangeEvent -> ViewpagerChangeEvent -> Bool
== :: ViewpagerChangeEvent -> ViewpagerChangeEvent -> Bool
$c/= :: ViewpagerChangeEvent -> ViewpagerChangeEvent -> Bool
/= :: ViewpagerChangeEvent -> ViewpagerChangeEvent -> Bool
Eq)
viewpagerChangeDecoder :: Decoder ViewpagerChangeEvent
= [MisoString
"detail"] [MisoString]
-> (Value -> Parser ViewpagerChangeEvent)
-> Decoder ViewpagerChangeEvent
forall a. [MisoString] -> (Value -> Parser a) -> Decoder a
`at` Value -> Parser ViewpagerChangeEvent
details
where
details :: Value -> Parser ViewpagerChangeEvent
details = MisoString
-> (Object -> Parser ViewpagerChangeEvent)
-> Value
-> Parser ViewpagerChangeEvent
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"detail" ((Object -> Parser ViewpagerChangeEvent)
-> Value -> Parser ViewpagerChangeEvent)
-> (Object -> Parser ViewpagerChangeEvent)
-> Value
-> Parser ViewpagerChangeEvent
forall a b. (a -> b) -> a -> b
$ \Object
o ->
Int -> Bool -> ViewpagerChangeEvent
ViewpagerChangeEvent
(Int -> Bool -> ViewpagerChangeEvent)
-> Parser Int -> Parser (Bool -> ViewpagerChangeEvent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> MisoString -> Parser Int
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"index"
Parser (Bool -> ViewpagerChangeEvent)
-> Parser Bool -> Parser ViewpagerChangeEvent
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 Bool
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"isDragged"
offsetChangeDecoder :: Decoder Double
offsetChangeDecoder :: Decoder Double
offsetChangeDecoder = [MisoString
"detail"] [MisoString] -> (Value -> Parser Double) -> Decoder Double
forall a. [MisoString] -> (Value -> Parser a) -> Decoder a
`at` Value -> Parser Double
details
where
details :: Value -> Parser Double
details = MisoString -> (Object -> Parser Double) -> Value -> Parser Double
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"detail" ((Object -> Parser Double) -> Value -> Parser Double)
-> (Object -> Parser Double) -> Value -> Parser Double
forall a b. (a -> b) -> a -> b
$ \Object
o -> Object
o Object -> MisoString -> Parser Double
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"offset"
onChange :: (ViewpagerChangeEvent -> action) -> Attribute model action
onChange :: forall action model.
(ViewpagerChangeEvent -> action) -> Attribute model action
onChange ViewpagerChangeEvent -> action
action = MisoString
-> Decoder ViewpagerChangeEvent
-> (ViewpagerChangeEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"change" Decoder ViewpagerChangeEvent
viewpagerChangeDecoder (\ViewpagerChangeEvent
e model
_ DOMRef
_ -> ViewpagerChangeEvent -> action
action ViewpagerChangeEvent
e)
onChangeMain :: (ViewpagerChangeEvent -> action) -> EventHandler model action
onChangeMain :: forall action model.
(ViewpagerChangeEvent -> action) -> EventHandler model action
onChangeMain ViewpagerChangeEvent -> action
action = MisoString
-> Decoder ViewpagerChangeEvent
-> (ViewpagerChangeEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"change" Decoder ViewpagerChangeEvent
viewpagerChangeDecoder (\ViewpagerChangeEvent
e model
_ DOMRef
_ -> ViewpagerChangeEvent -> action
action ViewpagerChangeEvent
e)
onChangeMainWith :: (ViewpagerChangeEvent -> model -> DOMRef -> action) -> EventHandler model action
onChangeMainWith :: forall model action.
(ViewpagerChangeEvent -> model -> DOMRef -> action)
-> EventHandler model action
onChangeMainWith ViewpagerChangeEvent -> model -> DOMRef -> action
action = MisoString
-> Decoder ViewpagerChangeEvent
-> (ViewpagerChangeEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"change" Decoder ViewpagerChangeEvent
viewpagerChangeDecoder ViewpagerChangeEvent -> model -> DOMRef -> action
action
onOffsetChange :: (Double -> action) -> Attribute model action
onOffsetChange :: forall action model. (Double -> action) -> Attribute model action
onOffsetChange Double -> action
action = MisoString
-> Decoder Double
-> (Double -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"offsetchange" Decoder Double
offsetChangeDecoder (\Double
e model
_ DOMRef
_ -> Double -> action
action Double
e)
onOffsetChangeMain :: (Double -> action) -> EventHandler model action
onOffsetChangeMain :: forall action model.
(Double -> action) -> EventHandler model action
onOffsetChangeMain Double -> action
action = MisoString
-> Decoder Double
-> (Double -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"offsetchange" Decoder Double
offsetChangeDecoder (\Double
e model
_ DOMRef
_ -> Double -> action
action Double
e)
onOffsetChangeMainWith :: (Double -> model -> DOMRef -> action) -> EventHandler model action
onOffsetChangeMainWith :: forall model action.
(Double -> model -> DOMRef -> action) -> EventHandler model action
onOffsetChangeMainWith Double -> model -> DOMRef -> action
action = MisoString
-> Decoder Double
-> (Double -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"offsetchange" Decoder Double
offsetChangeDecoder Double -> model -> DOMRef -> action
action
onWillChange :: (ViewpagerChangeEvent -> action) -> Attribute model action
onWillChange :: forall action model.
(ViewpagerChangeEvent -> action) -> Attribute model action
onWillChange ViewpagerChangeEvent -> action
action = MisoString
-> Decoder ViewpagerChangeEvent
-> (ViewpagerChangeEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"willchange" Decoder ViewpagerChangeEvent
viewpagerChangeDecoder (\ViewpagerChangeEvent
e model
_ DOMRef
_ -> ViewpagerChangeEvent -> action
action ViewpagerChangeEvent
e)
onWillChangeMain :: (ViewpagerChangeEvent -> action) -> EventHandler model action
onWillChangeMain :: forall action model.
(ViewpagerChangeEvent -> action) -> EventHandler model action
onWillChangeMain ViewpagerChangeEvent -> action
action = MisoString
-> Decoder ViewpagerChangeEvent
-> (ViewpagerChangeEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"willchange" Decoder ViewpagerChangeEvent
viewpagerChangeDecoder (\ViewpagerChangeEvent
e model
_ DOMRef
_ -> ViewpagerChangeEvent -> action
action ViewpagerChangeEvent
e)
onWillChangeMainWith :: (ViewpagerChangeEvent -> model -> DOMRef -> action) -> EventHandler model action
onWillChangeMainWith :: forall model action.
(ViewpagerChangeEvent -> model -> DOMRef -> action)
-> EventHandler model action
onWillChangeMainWith ViewpagerChangeEvent -> model -> DOMRef -> action
action = MisoString
-> Decoder ViewpagerChangeEvent
-> (ViewpagerChangeEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"willchange" Decoder ViewpagerChangeEvent
viewpagerChangeDecoder ViewpagerChangeEvent -> model -> DOMRef -> action
action
onChangeWith :: (ViewpagerChangeEvent -> DOMRef -> action) -> Attribute model action
onChangeWith :: forall action model.
(ViewpagerChangeEvent -> DOMRef -> action)
-> Attribute model action
onChangeWith ViewpagerChangeEvent -> DOMRef -> action
action = MisoString
-> Decoder ViewpagerChangeEvent
-> (ViewpagerChangeEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"change" Decoder ViewpagerChangeEvent
viewpagerChangeDecoder ((ViewpagerChangeEvent -> model -> DOMRef -> action)
-> Attribute model action)
-> (ViewpagerChangeEvent -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \ViewpagerChangeEvent
vpce model
_ DOMRef
domRef -> ViewpagerChangeEvent -> DOMRef -> action
action ViewpagerChangeEvent
vpce DOMRef
domRef
onOffsetChangeWith :: (Double -> DOMRef -> action) -> Attribute model action
onOffsetChangeWith :: forall action model.
(Double -> DOMRef -> action) -> Attribute model action
onOffsetChangeWith Double -> DOMRef -> action
action = MisoString
-> Decoder Double
-> (Double -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"offsetchange" Decoder Double
offsetChangeDecoder ((Double -> model -> DOMRef -> action) -> Attribute model action)
-> (Double -> model -> DOMRef -> action) -> Attribute model action
forall a b. (a -> b) -> a -> b
$ \Double
vpce model
_ DOMRef
domRef -> Double -> DOMRef -> action
action Double
vpce DOMRef
domRef
onWillChangeWith :: (ViewpagerChangeEvent -> DOMRef -> action) -> Attribute model action
onWillChangeWith :: forall action model.
(ViewpagerChangeEvent -> DOMRef -> action)
-> Attribute model action
onWillChangeWith ViewpagerChangeEvent -> DOMRef -> action
action = MisoString
-> Decoder ViewpagerChangeEvent
-> (ViewpagerChangeEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"willchange" Decoder ViewpagerChangeEvent
viewpagerChangeDecoder ((ViewpagerChangeEvent -> model -> DOMRef -> action)
-> Attribute model action)
-> (ViewpagerChangeEvent -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \ViewpagerChangeEvent
vpce model
_ DOMRef
domRef -> ViewpagerChangeEvent -> DOMRef -> action
action ViewpagerChangeEvent
vpce DOMRef
domRef