-----------------------------------------------------------------------------
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Miso.Native.Element.List.Event
-- Copyright   :  (C) 2016-2026 David M. Johnson
-- License     :  BSD3-style (see the file LICENSE)
-- Maintainer  :  David M. Johnson <code@dmj.io>
-- Stability   :  experimental
-- Portability :  non-portable
----------------------------------------------------------------------------
module Miso.Native.Element.List.Event
  ( -- *** Event
    onScroll
  , onScrollWith
  , onScrollMain
  , onScrollMainWith
  , onScrollToUpper
  , onScrollToUpperWith
  , onScrollToUpperMain
  , onScrollToUpperMainWith
  , onScrollToLower
  , onScrollToLowerWith
  , onScrollToLowerMain
  , onScrollToLowerMainWith
  , onScrollStateChange
  , onScrollStateChangeWith
  , onScrollStateChangeMain
  , onScrollStateChangeMainWith
  , onLayoutComplete
  , onLayoutCompleteWith
  , onLayoutCompleteMain
  , onLayoutCompleteMainWith
  , onSnap
  , onSnapWith
  , onSnapMain
  , onSnapMainWith
  -- *** Types
  , ScrollEvent (..)
  , SnapEvent (..)
  , LayoutCompleteEvent (..)
  , DiffResult (..)
  , ListEventSource (..)
  , Cell (..)
  , ScrollStateChange (..)
  -- *** Decoder
  , scrollDecoder
  , snapDecoder
  , layoutCompleteDecoder
  -- *** Event Map
  , listEvents
  ) where
-----------------------------------------------------------------------------
import qualified Data.Map as M
-----------------------------------------------------------------------------
import           Miso.Event
import           Miso.JSON
import           Miso.Types (Attribute, EventHandler, DOMRef)
import           Miso.String (MisoString)
-----------------------------------------------------------------------------
listEvents :: Events
listEvents :: Events
listEvents
  = [(MisoString, Phase)] -> Events
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList
  [ (MisoString
"scroll", Phase
BUBBLE)
  , (MisoString
"scrolltoupper", Phase
BUBBLE)
  , (MisoString
"scrolltolower", Phase
BUBBLE)
  , (MisoString
"scrollstatechange", Phase
BUBBLE)
  , (MisoString
"layoutcomplete", Phase
BUBBLE)
  , (MisoString
"snap", Phase
BUBBLE)
  ]
-----------------------------------------------------------------------------
scrollDecoder :: Decoder ScrollEvent
scrollDecoder :: Decoder ScrollEvent
scrollDecoder = [MisoString
"detail"] [MisoString]
-> (Value -> Parser ScrollEvent) -> Decoder ScrollEvent
forall a. [MisoString] -> (Value -> Parser a) -> Decoder a
`at` Value -> Parser ScrollEvent
forall a. FromJSON a => Value -> Parser a
parseJSON
-----------------------------------------------------------------------------
instance FromJSON ScrollEvent where
  parseJSON :: Value -> Parser ScrollEvent
parseJSON = MisoString
-> (Object -> Parser ScrollEvent) -> Value -> Parser ScrollEvent
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"ScrollEvent" ((Object -> Parser ScrollEvent) -> Value -> Parser ScrollEvent)
-> (Object -> Parser ScrollEvent) -> Value -> Parser ScrollEvent
forall a b. (a -> b) -> a -> b
$ \Object
o ->
    Double
-> Double
-> Double
-> Double
-> Double
-> Double
-> Double
-> Double
-> ListEventSource
-> [Cell]
-> ScrollEvent
ScrollEvent
      (Double
 -> Double
 -> Double
 -> Double
 -> Double
 -> Double
 -> Double
 -> Double
 -> ListEventSource
 -> [Cell]
 -> ScrollEvent)
-> Parser Double
-> Parser
     (Double
      -> Double
      -> Double
      -> Double
      -> Double
      -> Double
      -> Double
      -> ListEventSource
      -> [Cell]
      -> ScrollEvent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> MisoString -> Parser (Maybe Double)
forall a. FromJSON a => Object -> MisoString -> Parser (Maybe a)
.:? MisoString
"deltaX" Parser (Maybe Double) -> Double -> Parser Double
forall a. Parser (Maybe a) -> a -> Parser a
.!= Double
0
      Parser
  (Double
   -> Double
   -> Double
   -> Double
   -> Double
   -> Double
   -> Double
   -> ListEventSource
   -> [Cell]
   -> ScrollEvent)
-> Parser Double
-> Parser
     (Double
      -> Double
      -> Double
      -> Double
      -> Double
      -> Double
      -> ListEventSource
      -> [Cell]
      -> ScrollEvent)
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 (Maybe Double)
forall a. FromJSON a => Object -> MisoString -> Parser (Maybe a)
.:? MisoString
"deltaY" Parser (Maybe Double) -> Double -> Parser Double
forall a. Parser (Maybe a) -> a -> Parser a
.!= Double
0
      Parser
  (Double
   -> Double
   -> Double
   -> Double
   -> Double
   -> Double
   -> ListEventSource
   -> [Cell]
   -> ScrollEvent)
-> Parser Double
-> Parser
     (Double
      -> Double
      -> Double
      -> Double
      -> Double
      -> ListEventSource
      -> [Cell]
      -> ScrollEvent)
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 (Maybe Double)
forall a. FromJSON a => Object -> MisoString -> Parser (Maybe a)
.:? MisoString
"scrollLeft" Parser (Maybe Double) -> Double -> Parser Double
forall a. Parser (Maybe a) -> a -> Parser a
.!= Double
0
      Parser
  (Double
   -> Double
   -> Double
   -> Double
   -> Double
   -> ListEventSource
   -> [Cell]
   -> ScrollEvent)
-> Parser Double
-> Parser
     (Double
      -> Double
      -> Double
      -> Double
      -> ListEventSource
      -> [Cell]
      -> ScrollEvent)
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 (Maybe Double)
forall a. FromJSON a => Object -> MisoString -> Parser (Maybe a)
.:? MisoString
"scrollTop" Parser (Maybe Double) -> Double -> Parser Double
forall a. Parser (Maybe a) -> a -> Parser a
.!= Double
0
      Parser
  (Double
   -> Double
   -> Double
   -> Double
   -> ListEventSource
   -> [Cell]
   -> ScrollEvent)
-> Parser Double
-> Parser
     (Double
      -> Double -> Double -> ListEventSource -> [Cell] -> ScrollEvent)
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 (Maybe Double)
forall a. FromJSON a => Object -> MisoString -> Parser (Maybe a)
.:? MisoString
"scrollWidth" Parser (Maybe Double) -> Double -> Parser Double
forall a. Parser (Maybe a) -> a -> Parser a
.!= Double
0
      Parser
  (Double
   -> Double -> Double -> ListEventSource -> [Cell] -> ScrollEvent)
-> Parser Double
-> Parser
     (Double -> Double -> ListEventSource -> [Cell] -> ScrollEvent)
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 (Maybe Double)
forall a. FromJSON a => Object -> MisoString -> Parser (Maybe a)
.:? MisoString
"scrollHeight" Parser (Maybe Double) -> Double -> Parser Double
forall a. Parser (Maybe a) -> a -> Parser a
.!= Double
0
      Parser
  (Double -> Double -> ListEventSource -> [Cell] -> ScrollEvent)
-> Parser Double
-> Parser (Double -> ListEventSource -> [Cell] -> ScrollEvent)
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 (Maybe Double)
forall a. FromJSON a => Object -> MisoString -> Parser (Maybe a)
.:? MisoString
"listWidth" Parser (Maybe Double) -> Double -> Parser Double
forall a. Parser (Maybe a) -> a -> Parser a
.!= Double
0
      Parser (Double -> ListEventSource -> [Cell] -> ScrollEvent)
-> Parser Double
-> Parser (ListEventSource -> [Cell] -> ScrollEvent)
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 (Maybe Double)
forall a. FromJSON a => Object -> MisoString -> Parser (Maybe a)
.:? MisoString
"listHeight" Parser (Maybe Double) -> Double -> Parser Double
forall a. Parser (Maybe a) -> a -> Parser a
.!= Double
0
      -- `eventSource`/`attachedCells` are declared required in Lynx's
      -- ListScrollInfo, but `attachedCells` is only populated when
      -- `need-visible-item-info` is enabled (otherwise absent). Decode
      -- defensively so a `scroll` event without them still succeeds.
      Parser (ListEventSource -> [Cell] -> ScrollEvent)
-> Parser ListEventSource -> Parser ([Cell] -> ScrollEvent)
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 (Maybe ListEventSource)
forall a. FromJSON a => Object -> MisoString -> Parser (Maybe a)
.:? MisoString
"eventSource" Parser (Maybe ListEventSource)
-> ListEventSource -> Parser ListEventSource
forall a. Parser (Maybe a) -> a -> Parser a
.!= ListEventSource
SCROLL
      Parser ([Cell] -> ScrollEvent)
-> Parser [Cell] -> Parser ScrollEvent
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 (Maybe [Cell])
forall a. FromJSON a => Object -> MisoString -> Parser (Maybe a)
.:? MisoString
"attachedCells" Parser (Maybe [Cell]) -> [Cell] -> Parser [Cell]
forall a. Parser (Maybe a) -> a -> Parser a
.!= []
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/list.html#scroll
data ScrollEvent
  = ScrollEvent
  { ScrollEvent -> Double
deltaX, ScrollEvent -> Double
deltaY :: Double
  -- ^ Horizontal / vertical scroll offset since the last scroll, in px
  , ScrollEvent -> Double
scrollLeft, ScrollEvent -> Double
scrollTop :: Double
  -- ^ Current horizontal / vertical scroll offset, in px
  , ScrollEvent -> Double
scrollWidth, ScrollEvent -> Double
scrollHeight :: Double
  -- ^ Current content area height / width, in px
  , ScrollEvent -> Double
listWidth, ScrollEvent -> Double
listHeight :: Double
  -- ^ List width / height in px
  , ScrollEvent -> ListEventSource
listEventSource :: ListEventSource
  -- ^ Scroll event source
  , ScrollEvent -> [Cell]
attachedCells :: [Cell]
  -- ^ Attached cells
  } deriving (Int -> ScrollEvent -> ShowS
[ScrollEvent] -> ShowS
ScrollEvent -> String
(Int -> ScrollEvent -> ShowS)
-> (ScrollEvent -> String)
-> ([ScrollEvent] -> ShowS)
-> Show ScrollEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScrollEvent -> ShowS
showsPrec :: Int -> ScrollEvent -> ShowS
$cshow :: ScrollEvent -> String
show :: ScrollEvent -> String
$cshowList :: [ScrollEvent] -> ShowS
showList :: [ScrollEvent] -> ShowS
Show, ScrollEvent -> ScrollEvent -> Bool
(ScrollEvent -> ScrollEvent -> Bool)
-> (ScrollEvent -> ScrollEvent -> Bool) -> Eq ScrollEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScrollEvent -> ScrollEvent -> Bool
== :: ScrollEvent -> ScrollEvent -> Bool
$c/= :: ScrollEvent -> ScrollEvent -> Bool
/= :: ScrollEvent -> ScrollEvent -> Bool
Eq)
-----------------------------------------------------------------------------
data Cell
  = Cell
  { Cell -> MisoString
cellId :: MisoString
  -- ^ Node id (Lynx types this @ListAttachedCell.id@ as a string)
  , Cell -> MisoString
cellItemKey :: MisoString
  -- ^ Node item-key
  , Cell -> Double
cellIndex, Cell -> Double
cellLeft, Cell -> Double
cellTop, Cell -> Double
cellRight, Cell -> Double
cellBottom :: Double
  -- ^ Node left/top/right/bottom boundary position relative to list, in px
  } deriving (Int -> Cell -> ShowS
[Cell] -> ShowS
Cell -> String
(Int -> Cell -> ShowS)
-> (Cell -> String) -> ([Cell] -> ShowS) -> Show Cell
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Cell -> ShowS
showsPrec :: Int -> Cell -> ShowS
$cshow :: Cell -> String
show :: Cell -> String
$cshowList :: [Cell] -> ShowS
showList :: [Cell] -> ShowS
Show, Cell -> Cell -> Bool
(Cell -> Cell -> Bool) -> (Cell -> Cell -> Bool) -> Eq Cell
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Cell -> Cell -> Bool
== :: Cell -> Cell -> Bool
$c/= :: Cell -> Cell -> Bool
/= :: Cell -> Cell -> Bool
Eq)
-----------------------------------------------------------------------------
instance FromJSON Cell where
  parseJSON :: Value -> Parser Cell
parseJSON = MisoString -> (Object -> Parser Cell) -> Value -> Parser Cell
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"Cell" ((Object -> Parser Cell) -> Value -> Parser Cell)
-> (Object -> Parser Cell) -> Value -> Parser Cell
forall a b. (a -> b) -> a -> b
$ \Object
cell -> MisoString
-> MisoString
-> Double
-> Double
-> Double
-> Double
-> Double
-> Cell
Cell
    (MisoString
 -> MisoString
 -> Double
 -> Double
 -> Double
 -> Double
 -> Double
 -> Cell)
-> Parser MisoString
-> Parser
     (MisoString
      -> Double -> Double -> Double -> Double -> Double -> Cell)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
cell Object -> MisoString -> Parser MisoString
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"id"
    Parser
  (MisoString
   -> Double -> Double -> Double -> Double -> Double -> Cell)
-> Parser MisoString
-> Parser (Double -> Double -> Double -> Double -> Double -> Cell)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
cell Object -> MisoString -> Parser MisoString
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"itemKey"
    Parser (Double -> Double -> Double -> Double -> Double -> Cell)
-> Parser Double
-> Parser (Double -> Double -> Double -> Double -> Cell)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
cell Object -> MisoString -> Parser Double
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"index"
    Parser (Double -> Double -> Double -> Double -> Cell)
-> Parser Double -> Parser (Double -> Double -> Double -> Cell)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
cell Object -> MisoString -> Parser Double
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"left"
    Parser (Double -> Double -> Double -> Cell)
-> Parser Double -> Parser (Double -> Double -> Cell)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
cell Object -> MisoString -> Parser Double
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"top"
    Parser (Double -> Double -> Cell)
-> Parser Double -> Parser (Double -> Cell)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
cell Object -> MisoString -> Parser Double
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"right"
    Parser (Double -> Cell) -> Parser Double -> Parser Cell
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
cell Object -> MisoString -> Parser Double
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"bottom"
-----------------------------------------------------------------------------
data ListEventSource
  = DIFF
  | LAYOUT
  | SCROLL
  deriving (Int -> ListEventSource -> ShowS
[ListEventSource] -> ShowS
ListEventSource -> String
(Int -> ListEventSource -> ShowS)
-> (ListEventSource -> String)
-> ([ListEventSource] -> ShowS)
-> Show ListEventSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ListEventSource -> ShowS
showsPrec :: Int -> ListEventSource -> ShowS
$cshow :: ListEventSource -> String
show :: ListEventSource -> String
$cshowList :: [ListEventSource] -> ShowS
showList :: [ListEventSource] -> ShowS
Show, ListEventSource -> ListEventSource -> Bool
(ListEventSource -> ListEventSource -> Bool)
-> (ListEventSource -> ListEventSource -> Bool)
-> Eq ListEventSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ListEventSource -> ListEventSource -> Bool
== :: ListEventSource -> ListEventSource -> Bool
$c/= :: ListEventSource -> ListEventSource -> Bool
/= :: ListEventSource -> ListEventSource -> Bool
Eq, Int -> ListEventSource
ListEventSource -> Int
ListEventSource -> [ListEventSource]
ListEventSource -> ListEventSource
ListEventSource -> ListEventSource -> [ListEventSource]
ListEventSource
-> ListEventSource -> ListEventSource -> [ListEventSource]
(ListEventSource -> ListEventSource)
-> (ListEventSource -> ListEventSource)
-> (Int -> ListEventSource)
-> (ListEventSource -> Int)
-> (ListEventSource -> [ListEventSource])
-> (ListEventSource -> ListEventSource -> [ListEventSource])
-> (ListEventSource -> ListEventSource -> [ListEventSource])
-> (ListEventSource
    -> ListEventSource -> ListEventSource -> [ListEventSource])
-> Enum ListEventSource
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: ListEventSource -> ListEventSource
succ :: ListEventSource -> ListEventSource
$cpred :: ListEventSource -> ListEventSource
pred :: ListEventSource -> ListEventSource
$ctoEnum :: Int -> ListEventSource
toEnum :: Int -> ListEventSource
$cfromEnum :: ListEventSource -> Int
fromEnum :: ListEventSource -> Int
$cenumFrom :: ListEventSource -> [ListEventSource]
enumFrom :: ListEventSource -> [ListEventSource]
$cenumFromThen :: ListEventSource -> ListEventSource -> [ListEventSource]
enumFromThen :: ListEventSource -> ListEventSource -> [ListEventSource]
$cenumFromTo :: ListEventSource -> ListEventSource -> [ListEventSource]
enumFromTo :: ListEventSource -> ListEventSource -> [ListEventSource]
$cenumFromThenTo :: ListEventSource
-> ListEventSource -> ListEventSource -> [ListEventSource]
enumFromThenTo :: ListEventSource
-> ListEventSource -> ListEventSource -> [ListEventSource]
Enum)
-----------------------------------------------------------------------------
instance FromJSON ListEventSource where
  parseJSON :: Value -> Parser ListEventSource
parseJSON = MisoString
-> (Double -> Parser ListEventSource)
-> Value
-> Parser ListEventSource
forall a. MisoString -> (Double -> Parser a) -> Value -> Parser a
withNumber MisoString
"ListEventSource" ((Double -> Parser ListEventSource)
 -> Value -> Parser ListEventSource)
-> (Double -> Parser ListEventSource)
-> Value
-> Parser ListEventSource
forall a b. (a -> b) -> a -> b
$ \case
    Double
0 -> ListEventSource -> Parser ListEventSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ListEventSource
DIFF
    Double
1 -> ListEventSource -> Parser ListEventSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ListEventSource
LAYOUT
    Double
2 -> ListEventSource -> Parser ListEventSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ListEventSource
SCROLL
    Double
x -> MisoString -> Value -> Parser ListEventSource
forall a. MisoString -> Value -> Parser a
typeMismatch MisoString
"ListEventSource" (Double -> Value
Number Double
x)
-----------------------------------------------------------------------------
data ScrollStateChange
  = Stationary
  | Dragging
  | InertialScrolling
  | SmoothAnimationScrolling
  deriving (Int -> ScrollStateChange -> ShowS
[ScrollStateChange] -> ShowS
ScrollStateChange -> String
(Int -> ScrollStateChange -> ShowS)
-> (ScrollStateChange -> String)
-> ([ScrollStateChange] -> ShowS)
-> Show ScrollStateChange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScrollStateChange -> ShowS
showsPrec :: Int -> ScrollStateChange -> ShowS
$cshow :: ScrollStateChange -> String
show :: ScrollStateChange -> String
$cshowList :: [ScrollStateChange] -> ShowS
showList :: [ScrollStateChange] -> ShowS
Show, ScrollStateChange -> ScrollStateChange -> Bool
(ScrollStateChange -> ScrollStateChange -> Bool)
-> (ScrollStateChange -> ScrollStateChange -> Bool)
-> Eq ScrollStateChange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScrollStateChange -> ScrollStateChange -> Bool
== :: ScrollStateChange -> ScrollStateChange -> Bool
$c/= :: ScrollStateChange -> ScrollStateChange -> Bool
/= :: ScrollStateChange -> ScrollStateChange -> Bool
Eq)
-----------------------------------------------------------------------------
-- | Numbering matches Lynx's @ScrollState@ enum (@kIdle = 1@ … @kScrollAnimation
-- = 4@), so 'toEnum'\/'fromEnum' agree with the wire and with 'FromJSON' below.
-- (A derived 'Enum' would be 0-based and disagree with the values Lynx sends.)
instance Enum ScrollStateChange where
  fromEnum :: ScrollStateChange -> Int
fromEnum ScrollStateChange
Stationary               = Int
1
  fromEnum ScrollStateChange
Dragging                 = Int
2
  fromEnum ScrollStateChange
InertialScrolling        = Int
3
  fromEnum ScrollStateChange
SmoothAnimationScrolling = Int
4
  toEnum :: Int -> ScrollStateChange
toEnum Int
1 = ScrollStateChange
Stationary
  toEnum Int
2 = ScrollStateChange
Dragging
  toEnum Int
3 = ScrollStateChange
InertialScrolling
  toEnum Int
4 = ScrollStateChange
SmoothAnimationScrolling
  toEnum Int
n = String -> ScrollStateChange
forall a. HasCallStack => String -> a
error (String
"ScrollStateChange.toEnum: bad argument " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
n)
-----------------------------------------------------------------------------
instance FromJSON ScrollStateChange where
  parseJSON :: Value -> Parser ScrollStateChange
parseJSON = MisoString
-> (Double -> Parser ScrollStateChange)
-> Value
-> Parser ScrollStateChange
forall a. MisoString -> (Double -> Parser a) -> Value -> Parser a
withNumber MisoString
"ScrollStateChange" ((Double -> Parser ScrollStateChange)
 -> Value -> Parser ScrollStateChange)
-> (Double -> Parser ScrollStateChange)
-> Value
-> Parser ScrollStateChange
forall a b. (a -> b) -> a -> b
$ \case
    Double
1 -> ScrollStateChange -> Parser ScrollStateChange
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ScrollStateChange
Stationary
    Double
2 -> ScrollStateChange -> Parser ScrollStateChange
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ScrollStateChange
Dragging
    Double
3 -> ScrollStateChange -> Parser ScrollStateChange
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ScrollStateChange
InertialScrolling
    Double
4 -> ScrollStateChange -> Parser ScrollStateChange
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ScrollStateChange
SmoothAnimationScrolling
    Double
x -> MisoString -> Value -> Parser ScrollStateChange
forall a. MisoString -> Value -> Parser a
typeMismatch MisoString
"ScrollStateChange" (Double -> Value
Number Double
x)
-----------------------------------------------------------------------------
scrollStateDecoder :: Decoder ScrollStateChange
scrollStateDecoder :: Decoder ScrollStateChange
scrollStateDecoder = [MisoString
"detail"] [MisoString]
-> (Value -> Parser ScrollStateChange) -> Decoder ScrollStateChange
forall a. [MisoString] -> (Value -> Parser a) -> Decoder a
`at` MisoString
-> (Object -> Parser ScrollStateChange)
-> Value
-> Parser ScrollStateChange
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"ScrollStateChange" (Object -> MisoString -> Parser ScrollStateChange
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"state")
-----------------------------------------------------------------------------
data SnapEvent
  = SnapEvent
  { SnapEvent -> Double
position :: Double
  -- ^ The index of the node that will be paginated to
  , SnapEvent -> Double
currentScrollLeft :: Double
  -- ^ Current horizontal scroll offset, in px
  , SnapEvent -> Double
currentScrollTop :: Double
  -- ^ Current vertical scroll offset, in px
  , SnapEvent -> Double
targetScrollLeft :: Double
  -- ^ Target horizontal scroll offset for pagination, in px
  , SnapEvent -> Double
targetScrollTop :: Double
  -- ^ Target vertical scroll offset for pagination, in px
  } deriving (Int -> SnapEvent -> ShowS
[SnapEvent] -> ShowS
SnapEvent -> String
(Int -> SnapEvent -> ShowS)
-> (SnapEvent -> String)
-> ([SnapEvent] -> ShowS)
-> Show SnapEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SnapEvent -> ShowS
showsPrec :: Int -> SnapEvent -> ShowS
$cshow :: SnapEvent -> String
show :: SnapEvent -> String
$cshowList :: [SnapEvent] -> ShowS
showList :: [SnapEvent] -> ShowS
Show, SnapEvent -> SnapEvent -> Bool
(SnapEvent -> SnapEvent -> Bool)
-> (SnapEvent -> SnapEvent -> Bool) -> Eq SnapEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SnapEvent -> SnapEvent -> Bool
== :: SnapEvent -> SnapEvent -> Bool
$c/= :: SnapEvent -> SnapEvent -> Bool
/= :: SnapEvent -> SnapEvent -> Bool
Eq)
-----------------------------------------------------------------------------
snapDecoder :: Decoder SnapEvent
snapDecoder :: Decoder SnapEvent
snapDecoder = [MisoString
"detail"] [MisoString] -> (Value -> Parser SnapEvent) -> Decoder SnapEvent
forall a. [MisoString] -> (Value -> Parser a) -> Decoder a
`at` do
  MisoString
-> (Object -> Parser SnapEvent) -> Value -> Parser SnapEvent
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"SnapEvent" ((Object -> Parser SnapEvent) -> Value -> Parser SnapEvent)
-> (Object -> Parser SnapEvent) -> Value -> Parser SnapEvent
forall a b. (a -> b) -> a -> b
$ \Object
o ->
    Double -> Double -> Double -> Double -> Double -> SnapEvent
SnapEvent
      (Double -> Double -> Double -> Double -> Double -> SnapEvent)
-> Parser Double
-> Parser (Double -> Double -> Double -> Double -> SnapEvent)
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
"position"
      Parser (Double -> Double -> Double -> Double -> SnapEvent)
-> Parser Double
-> Parser (Double -> Double -> Double -> SnapEvent)
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
"currentScrollLeft"
      Parser (Double -> Double -> Double -> SnapEvent)
-> Parser Double -> Parser (Double -> Double -> SnapEvent)
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
"currentScrollTop"
      Parser (Double -> Double -> SnapEvent)
-> Parser Double -> Parser (Double -> SnapEvent)
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
"targetScrollLeft"
      Parser (Double -> SnapEvent) -> Parser Double -> Parser SnapEvent
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
"targetScrollTop"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/list.html#layoutcomplete
--
-- Enable 'needLayoutCompleteInfo' to use.
--
data LayoutCompleteEvent
  = LayoutCompleteEvent
  { LayoutCompleteEvent -> Double
layoutId :: Double
  , LayoutCompleteEvent -> ScrollEvent
scrollInfo :: ScrollEvent
  -- ^ Current horizontal scroll offset, in px
  , LayoutCompleteEvent -> Maybe DiffResult
diffResult :: Maybe DiffResult
  -- ^ Current vertical scroll offset, in px
  , LayoutCompleteEvent -> [ListItemInfo]
visibleCellsAfterUpdate :: [ListItemInfo]
  -- ^ Target horizontal scroll offset for pagination, in px
  , LayoutCompleteEvent -> [ListItemInfo]
visibleCellsBeforeUpdate :: [ListItemInfo]
  -- ^ Target vertical scroll offset for pagination, in px
  } deriving (Int -> LayoutCompleteEvent -> ShowS
[LayoutCompleteEvent] -> ShowS
LayoutCompleteEvent -> String
(Int -> LayoutCompleteEvent -> ShowS)
-> (LayoutCompleteEvent -> String)
-> ([LayoutCompleteEvent] -> ShowS)
-> Show LayoutCompleteEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LayoutCompleteEvent -> ShowS
showsPrec :: Int -> LayoutCompleteEvent -> ShowS
$cshow :: LayoutCompleteEvent -> String
show :: LayoutCompleteEvent -> String
$cshowList :: [LayoutCompleteEvent] -> ShowS
showList :: [LayoutCompleteEvent] -> ShowS
Show, LayoutCompleteEvent -> LayoutCompleteEvent -> Bool
(LayoutCompleteEvent -> LayoutCompleteEvent -> Bool)
-> (LayoutCompleteEvent -> LayoutCompleteEvent -> Bool)
-> Eq LayoutCompleteEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LayoutCompleteEvent -> LayoutCompleteEvent -> Bool
== :: LayoutCompleteEvent -> LayoutCompleteEvent -> Bool
$c/= :: LayoutCompleteEvent -> LayoutCompleteEvent -> Bool
/= :: LayoutCompleteEvent -> LayoutCompleteEvent -> Bool
Eq)
-----------------------------------------------------------------------------
data DiffResult
  = DiffResult
  { DiffResult -> [Double]
insertions :: [Double]
  , DiffResult -> [Double]
moveFrom :: [Double]
  , DiffResult -> [Double]
moveTo :: [Double]
  , DiffResult -> [Double]
removals :: [Double]
  , DiffResult -> [Double]
updateFrom :: [Double]
  , DiffResult -> [Double]
updateTo :: [Double]
  } deriving (Int -> DiffResult -> ShowS
[DiffResult] -> ShowS
DiffResult -> String
(Int -> DiffResult -> ShowS)
-> (DiffResult -> String)
-> ([DiffResult] -> ShowS)
-> Show DiffResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DiffResult -> ShowS
showsPrec :: Int -> DiffResult -> ShowS
$cshow :: DiffResult -> String
show :: DiffResult -> String
$cshowList :: [DiffResult] -> ShowS
showList :: [DiffResult] -> ShowS
Show, DiffResult -> DiffResult -> Bool
(DiffResult -> DiffResult -> Bool)
-> (DiffResult -> DiffResult -> Bool) -> Eq DiffResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DiffResult -> DiffResult -> Bool
== :: DiffResult -> DiffResult -> Bool
$c/= :: DiffResult -> DiffResult -> Bool
/= :: DiffResult -> DiffResult -> Bool
Eq)
-----------------------------------------------------------------------------
instance FromJSON DiffResult where
  parseJSON :: Value -> Parser DiffResult
parseJSON = MisoString
-> (Object -> Parser DiffResult) -> Value -> Parser DiffResult
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"DiffResult" ((Object -> Parser DiffResult) -> Value -> Parser DiffResult)
-> (Object -> Parser DiffResult) -> Value -> Parser DiffResult
forall a b. (a -> b) -> a -> b
$ \Object
o ->
    [Double]
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> [Double]
-> DiffResult
DiffResult
      ([Double]
 -> [Double]
 -> [Double]
 -> [Double]
 -> [Double]
 -> [Double]
 -> DiffResult)
-> Parser [Double]
-> Parser
     ([Double]
      -> [Double] -> [Double] -> [Double] -> [Double] -> DiffResult)
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
"insertions"
      Parser
  ([Double]
   -> [Double] -> [Double] -> [Double] -> [Double] -> DiffResult)
-> Parser [Double]
-> Parser
     ([Double] -> [Double] -> [Double] -> [Double] -> DiffResult)
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
"move_from"
      Parser ([Double] -> [Double] -> [Double] -> [Double] -> DiffResult)
-> Parser [Double]
-> Parser ([Double] -> [Double] -> [Double] -> DiffResult)
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
"move_to"
      Parser ([Double] -> [Double] -> [Double] -> DiffResult)
-> Parser [Double] -> Parser ([Double] -> [Double] -> DiffResult)
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
"removals"
      Parser ([Double] -> [Double] -> DiffResult)
-> Parser [Double] -> Parser ([Double] -> DiffResult)
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
"update_from"
      Parser ([Double] -> DiffResult)
-> Parser [Double] -> Parser DiffResult
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
"update_to"
-----------------------------------------------------------------------------
data ListItemInfo
  = ListItemInfo
  { ListItemInfo -> Double
listItemInfoHeight :: Double
    -- ^ Child node height
  , ListItemInfo -> Double
listItemInfoWidth :: Double
    -- ^ Child node width
  , ListItemInfo -> MisoString
listItemInfoItemKey :: MisoString
    -- ^ Child node ItemKey
  , ListItemInfo -> Bool
listItemInfoIsBinding :: Bool
    -- ^ Whether the child node is in rendering state
  , ListItemInfo -> Double
listItemInfoOriginX :: Double
    -- ^ X coordinate position of the child node relative to the entire scroll area
  , ListItemInfo -> Double
listItemInfoOriginY :: Double
    -- ^ Y coordinate position of the child node relative to the entire scroll area
  , ListItemInfo -> Bool
listItemInfoUpdated :: Bool
    -- ^ Whether the child node has been updated
  } deriving (Int -> ListItemInfo -> ShowS
[ListItemInfo] -> ShowS
ListItemInfo -> String
(Int -> ListItemInfo -> ShowS)
-> (ListItemInfo -> String)
-> ([ListItemInfo] -> ShowS)
-> Show ListItemInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ListItemInfo -> ShowS
showsPrec :: Int -> ListItemInfo -> ShowS
$cshow :: ListItemInfo -> String
show :: ListItemInfo -> String
$cshowList :: [ListItemInfo] -> ShowS
showList :: [ListItemInfo] -> ShowS
Show, ListItemInfo -> ListItemInfo -> Bool
(ListItemInfo -> ListItemInfo -> Bool)
-> (ListItemInfo -> ListItemInfo -> Bool) -> Eq ListItemInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ListItemInfo -> ListItemInfo -> Bool
== :: ListItemInfo -> ListItemInfo -> Bool
$c/= :: ListItemInfo -> ListItemInfo -> Bool
/= :: ListItemInfo -> ListItemInfo -> Bool
Eq)
-----------------------------------------------------------------------------
instance FromJSON ListItemInfo where
  parseJSON :: Value -> Parser ListItemInfo
parseJSON = MisoString
-> (Object -> Parser ListItemInfo) -> Value -> Parser ListItemInfo
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"ListItemInfo" ((Object -> Parser ListItemInfo) -> Value -> Parser ListItemInfo)
-> (Object -> Parser ListItemInfo) -> Value -> Parser ListItemInfo
forall a b. (a -> b) -> a -> b
$ \Object
o ->
    Double
-> Double
-> MisoString
-> Bool
-> Double
-> Double
-> Bool
-> ListItemInfo
ListItemInfo
      (Double
 -> Double
 -> MisoString
 -> Bool
 -> Double
 -> Double
 -> Bool
 -> ListItemInfo)
-> Parser Double
-> Parser
     (Double
      -> MisoString -> Bool -> Double -> Double -> Bool -> ListItemInfo)
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
   -> MisoString -> Bool -> Double -> Double -> Bool -> ListItemInfo)
-> Parser Double
-> Parser
     (MisoString -> Bool -> Double -> Double -> Bool -> ListItemInfo)
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
"width"
      Parser
  (MisoString -> Bool -> Double -> Double -> Bool -> ListItemInfo)
-> Parser MisoString
-> Parser (Bool -> Double -> Double -> Bool -> ListItemInfo)
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 MisoString
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"itemKey"
      Parser (Bool -> Double -> Double -> Bool -> ListItemInfo)
-> Parser Bool -> Parser (Double -> Double -> Bool -> ListItemInfo)
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
"isBinding"
      Parser (Double -> Double -> Bool -> ListItemInfo)
-> Parser Double -> Parser (Double -> Bool -> ListItemInfo)
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
"originX"
      Parser (Double -> Bool -> ListItemInfo)
-> Parser Double -> Parser (Bool -> ListItemInfo)
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
"originY"
      Parser (Bool -> ListItemInfo) -> Parser Bool -> Parser ListItemInfo
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
"updated"
-----------------------------------------------------------------------------
layoutCompleteDecoder :: Decoder LayoutCompleteEvent
layoutCompleteDecoder :: Decoder LayoutCompleteEvent
layoutCompleteDecoder = [MisoString
"detail"] [MisoString]
-> (Value -> Parser LayoutCompleteEvent)
-> Decoder LayoutCompleteEvent
forall a. [MisoString] -> (Value -> Parser a) -> Decoder a
`at` do
  MisoString
-> (Object -> Parser LayoutCompleteEvent)
-> Value
-> Parser LayoutCompleteEvent
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"LayoutCompleteEvent" ((Object -> Parser LayoutCompleteEvent)
 -> Value -> Parser LayoutCompleteEvent)
-> (Object -> Parser LayoutCompleteEvent)
-> Value
-> Parser LayoutCompleteEvent
forall a b. (a -> b) -> a -> b
$ \Object
o ->
    Double
-> ScrollEvent
-> Maybe DiffResult
-> [ListItemInfo]
-> [ListItemInfo]
-> LayoutCompleteEvent
LayoutCompleteEvent
      (Double
 -> ScrollEvent
 -> Maybe DiffResult
 -> [ListItemInfo]
 -> [ListItemInfo]
 -> LayoutCompleteEvent)
-> Parser Double
-> Parser
     (ScrollEvent
      -> Maybe DiffResult
      -> [ListItemInfo]
      -> [ListItemInfo]
      -> LayoutCompleteEvent)
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
"layout-id"
      Parser
  (ScrollEvent
   -> Maybe DiffResult
   -> [ListItemInfo]
   -> [ListItemInfo]
   -> LayoutCompleteEvent)
-> Parser ScrollEvent
-> Parser
     (Maybe DiffResult
      -> [ListItemInfo] -> [ListItemInfo] -> LayoutCompleteEvent)
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 ScrollEvent
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"scrollInfo"
      Parser
  (Maybe DiffResult
   -> [ListItemInfo] -> [ListItemInfo] -> LayoutCompleteEvent)
-> Parser (Maybe DiffResult)
-> Parser ([ListItemInfo] -> [ListItemInfo] -> LayoutCompleteEvent)
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 (Maybe DiffResult)
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"diffResult"
      Parser ([ListItemInfo] -> [ListItemInfo] -> LayoutCompleteEvent)
-> Parser [ListItemInfo]
-> Parser ([ListItemInfo] -> LayoutCompleteEvent)
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 [ListItemInfo]
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"visibleCellsAfterUpdate"
      Parser ([ListItemInfo] -> LayoutCompleteEvent)
-> Parser [ListItemInfo] -> Parser LayoutCompleteEvent
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 [ListItemInfo]
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"visibleCellsBeforeUpdate"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/list.html#scroll
--
-- \<list\> scroll event.
--
-- @
--
-- data Action = HandleScroll ScrollEvent
--
-- view :: context -> props -> Model -> View context Action
-- view _ _ model = list_ defaultListOptions [ onScroll HandleScroll ] [ ]
--
-- update :: Action -> Effect props Model Action
-- update (HandleScroll ScrollEvent {..}) =
--   io_ (consoleLog "handled scroll event")
--
-- @
--
onScroll :: (ScrollEvent -> action) -> Attribute model action
onScroll :: forall action model.
(ScrollEvent -> action) -> Attribute model action
onScroll ScrollEvent -> action
action = MisoString
-> Decoder ScrollEvent
-> (ScrollEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"scroll" Decoder ScrollEvent
scrollDecoder (\ScrollEvent
x model
_ DOMRef
_ -> ScrollEvent -> action
action ScrollEvent
x)
-----------------------------------------------------------------------------
-- | Like 'onScroll', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = HandleScroll ScrollEvent
--
-- view_ [ event (static (onScrollMain HandleScroll)) ] [ "some view" ]
-- @
--
onScrollMain :: (ScrollEvent -> action) -> EventHandler model action
onScrollMain :: forall action model.
(ScrollEvent -> action) -> EventHandler model action
onScrollMain ScrollEvent -> action
action = MisoString
-> Decoder ScrollEvent
-> (ScrollEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"scroll" Decoder ScrollEvent
scrollDecoder (\ScrollEvent
x model
_ DOMRef
_ -> ScrollEvent -> action
action ScrollEvent
x)
-----------------------------------------------------------------------------
-- | Like 'onScrollMain', but the handler also receives read-only access to the
-- @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = HandleScroll ScrollEvent Model DOMRef
--
-- view_ [ event (static (onScrollMainWith HandleScroll)) ] [ "some view" ]
-- @
--
onScrollMainWith :: (ScrollEvent -> model -> DOMRef -> action) -> EventHandler model action
onScrollMainWith :: forall model action.
(ScrollEvent -> model -> DOMRef -> action)
-> EventHandler model action
onScrollMainWith ScrollEvent -> model -> DOMRef -> action
action = MisoString
-> Decoder ScrollEvent
-> (ScrollEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"scroll" Decoder ScrollEvent
scrollDecoder ScrollEvent -> model -> DOMRef -> action
action
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/list.html#scrolltoupper
--
-- Callback triggered when scrolling to the top of \<list\>. The trigger
-- position of this callback can be controlled by 'upperThresholdItemCount'.
--
-- @
--
-- data Action = HandleScroll ScrollEvent
--
-- view :: context -> props -> Model -> View context Action
-- view _ _ model = list_ defaultListOptions [ onScrollToUpper HandleScroll ] [ ]
--
-- update :: Action -> Effect props Model Action
-- update (HandleScroll ScrollEvent {..}) =
--   io_ (consoleLog "handled scroll event")
--
-- @
--
onScrollToUpper :: (ScrollEvent -> action) -> Attribute model action
onScrollToUpper :: forall action model.
(ScrollEvent -> action) -> Attribute model action
onScrollToUpper ScrollEvent -> action
action = MisoString
-> Decoder ScrollEvent
-> (ScrollEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"scrolltoupper" Decoder ScrollEvent
scrollDecoder (\ScrollEvent
x model
_ DOMRef
_ -> ScrollEvent -> action
action ScrollEvent
x)
-----------------------------------------------------------------------------
-- | Like 'onScrollToUpper', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = HandleScroll ScrollEvent
--
-- view_ [ event (static (onScrollToUpperMain HandleScroll)) ] [ "some view" ]
-- @
--
onScrollToUpperMain :: (ScrollEvent -> action) -> EventHandler model action
onScrollToUpperMain :: forall action model.
(ScrollEvent -> action) -> EventHandler model action
onScrollToUpperMain ScrollEvent -> action
action = MisoString
-> Decoder ScrollEvent
-> (ScrollEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"scrolltoupper" Decoder ScrollEvent
scrollDecoder (\ScrollEvent
x model
_ DOMRef
_ -> ScrollEvent -> action
action ScrollEvent
x)
-----------------------------------------------------------------------------
-- | Like 'onScrollToUpperMain', but the handler also receives read-only access
-- to the @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = HandleScroll ScrollEvent Model DOMRef
--
-- view_ [ event (static (onScrollToUpperMainWith HandleScroll)) ] [ "some view" ]
-- @
--
onScrollToUpperMainWith :: (ScrollEvent -> model -> DOMRef -> action) -> EventHandler model action
onScrollToUpperMainWith :: forall model action.
(ScrollEvent -> model -> DOMRef -> action)
-> EventHandler model action
onScrollToUpperMainWith ScrollEvent -> model -> DOMRef -> action
action = MisoString
-> Decoder ScrollEvent
-> (ScrollEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"scrolltoupper" Decoder ScrollEvent
scrollDecoder ScrollEvent -> model -> DOMRef -> action
action
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/list.html#scrolltolower
--
-- Callback triggered when scrolling to the bottom of \<list\>. The trigger
-- position of this callback can be controlled by 'lowerThresholdItemCount_'
--
-- @
--
-- data Action = HandleScroll ScrollEvent
--
-- view :: context -> props -> Model -> View context Action
-- view _ _ model = list_ defaultListOptions [ onScrollToLower HandleScroll ] [ ]
--
-- update :: Action -> Effect props Model Action
-- update (HandleScroll ScrollEvent {..}) =
--   io_ (consoleLog "handled scroll event")
--
-- @
--
onScrollToLower :: (ScrollEvent -> action) -> Attribute model action
onScrollToLower :: forall action model.
(ScrollEvent -> action) -> Attribute model action
onScrollToLower ScrollEvent -> action
action = MisoString
-> Decoder ScrollEvent
-> (ScrollEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"scrolltolower" Decoder ScrollEvent
scrollDecoder (\ScrollEvent
x model
_ DOMRef
_ -> ScrollEvent -> action
action ScrollEvent
x)
-----------------------------------------------------------------------------
-- | Like 'onScrollToLower', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = HandleScroll ScrollEvent
--
-- view_ [ event (static (onScrollToLowerMain HandleScroll)) ] [ "some view" ]
-- @
--
onScrollToLowerMain :: (ScrollEvent -> action) -> EventHandler model action
onScrollToLowerMain :: forall action model.
(ScrollEvent -> action) -> EventHandler model action
onScrollToLowerMain ScrollEvent -> action
action = MisoString
-> Decoder ScrollEvent
-> (ScrollEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"scrolltolower" Decoder ScrollEvent
scrollDecoder (\ScrollEvent
x model
_ DOMRef
_ -> ScrollEvent -> action
action ScrollEvent
x)
-----------------------------------------------------------------------------
-- | Like 'onScrollToLowerMain', but the handler also receives read-only access
-- to the @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = HandleScroll ScrollEvent Model DOMRef
--
-- view_ [ event (static (onScrollToLowerMainWith HandleScroll)) ] [ "some view" ]
-- @
--
onScrollToLowerMainWith :: (ScrollEvent -> model -> DOMRef -> action) -> EventHandler model action
onScrollToLowerMainWith :: forall model action.
(ScrollEvent -> model -> DOMRef -> action)
-> EventHandler model action
onScrollToLowerMainWith ScrollEvent -> model -> DOMRef -> action
action = MisoString
-> Decoder ScrollEvent
-> (ScrollEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"scrolltolower" Decoder ScrollEvent
scrollDecoder ScrollEvent -> model -> DOMRef -> action
action
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/list.html#scrollstatechange
--
-- Callback triggered when the scroll state of \<list\> changes. The state
-- field in the event parameter's detail indicates the scroll state:
-- * 1 for stationary
-- * 2 for dragging
-- * 3 for inertial scrolling
-- * 4 for smooth animation scrolling.
--
-- @
--
-- data Action = HandleScrollState ScrollStateChange
--
-- view :: context -> props -> Model -> View context Action
-- view _ _ model = list_ defaultListOptions [ onScrollStateChange HandleScrollState ] [ ]
--
-- update :: Action -> Effect props Model Action
-- update (HandleScroll Stationary) =
--   io_ (consoleLog "Received Stationary scroll state change")
-- update _ = pure ()
--
-- @
--
onScrollStateChange :: (ScrollStateChange -> action) -> Attribute model action
onScrollStateChange :: forall action model.
(ScrollStateChange -> action) -> Attribute model action
onScrollStateChange ScrollStateChange -> action
action = MisoString
-> Decoder ScrollStateChange
-> (ScrollStateChange -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"scrollstatechange" Decoder ScrollStateChange
scrollStateDecoder (\ScrollStateChange
x model
_ DOMRef
_ -> ScrollStateChange -> action
action ScrollStateChange
x)
-----------------------------------------------------------------------------
-- | Like 'onScrollStateChange', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = HandleScrollState ScrollStateChange
--
-- view_ [ event (static (onScrollStateChangeMain HandleScrollState)) ] [ "some view" ]
-- @
--
onScrollStateChangeMain :: (ScrollStateChange -> action) -> EventHandler model action
onScrollStateChangeMain :: forall action model.
(ScrollStateChange -> action) -> EventHandler model action
onScrollStateChangeMain ScrollStateChange -> action
action = MisoString
-> Decoder ScrollStateChange
-> (ScrollStateChange -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"scrollstatechange" Decoder ScrollStateChange
scrollStateDecoder (\ScrollStateChange
x model
_ DOMRef
_ -> ScrollStateChange -> action
action ScrollStateChange
x)
-----------------------------------------------------------------------------
-- | Like 'onScrollStateChangeMain', but the handler also receives read-only
-- access to the @model@ and the target element's 'DOMRef' (for imperative MTS
-- mutation).
--
-- @
-- data Action = HandleScrollState ScrollStateChange Model DOMRef
--
-- view_ [ event (static (onScrollStateChangeMainWith HandleScrollState)) ] [ "some view" ]
-- @
--
onScrollStateChangeMainWith :: (ScrollStateChange -> model -> DOMRef -> action) -> EventHandler model action
onScrollStateChangeMainWith :: forall model action.
(ScrollStateChange -> model -> DOMRef -> action)
-> EventHandler model action
onScrollStateChangeMainWith ScrollStateChange -> model -> DOMRef -> action
action = MisoString
-> Decoder ScrollStateChange
-> (ScrollStateChange -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"scrollstatechange" Decoder ScrollStateChange
scrollStateDecoder ScrollStateChange -> model -> DOMRef -> action
action
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/list.html#layoutcomplete
--
-- Callback triggered after \<list\> layout is complete.
--
-- @
--
-- data Action = HandleLayout LayoutCompleteEvent
--
-- view :: context -> props -> Model -> View context Action
-- view _ _ model = list_ defaultListOptions [ onLayoutComplete HandleLayout ] [ ]
--
-- update :: Action -> Effect props Model Action
-- update (HandleLayout LayoutCompleteEvent {..}) =
--   io_ (consoleLog "Received LayoutCompleteEvent")
--
-- @
--
onLayoutComplete :: (LayoutCompleteEvent -> action) -> Attribute model action
onLayoutComplete :: forall action model.
(LayoutCompleteEvent -> action) -> Attribute model action
onLayoutComplete LayoutCompleteEvent -> action
action = MisoString
-> Decoder LayoutCompleteEvent
-> (LayoutCompleteEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"layoutcomplete" Decoder LayoutCompleteEvent
layoutCompleteDecoder (\LayoutCompleteEvent
x model
_ DOMRef
_ -> LayoutCompleteEvent -> action
action LayoutCompleteEvent
x)
-----------------------------------------------------------------------------
-- | Like 'onLayoutComplete', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = HandleLayout LayoutCompleteEvent
--
-- view_ [ event (static (onLayoutCompleteMain HandleLayout)) ] [ "some view" ]
-- @
--
onLayoutCompleteMain :: (LayoutCompleteEvent -> action) -> EventHandler model action
onLayoutCompleteMain :: forall action model.
(LayoutCompleteEvent -> action) -> EventHandler model action
onLayoutCompleteMain LayoutCompleteEvent -> action
action = MisoString
-> Decoder LayoutCompleteEvent
-> (LayoutCompleteEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"layoutcomplete" Decoder LayoutCompleteEvent
layoutCompleteDecoder (\LayoutCompleteEvent
x model
_ DOMRef
_ -> LayoutCompleteEvent -> action
action LayoutCompleteEvent
x)
-----------------------------------------------------------------------------
-- | Like 'onLayoutCompleteMain', but the handler also receives read-only access
-- to the @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = HandleLayout LayoutCompleteEvent Model DOMRef
--
-- view_ [ event (static (onLayoutCompleteMainWith HandleLayout)) ] [ "some view" ]
-- @
--
onLayoutCompleteMainWith :: (LayoutCompleteEvent -> model -> DOMRef -> action) -> EventHandler model action
onLayoutCompleteMainWith :: forall model action.
(LayoutCompleteEvent -> model -> DOMRef -> action)
-> EventHandler model action
onLayoutCompleteMainWith LayoutCompleteEvent -> model -> DOMRef -> action
action = MisoString
-> Decoder LayoutCompleteEvent
-> (LayoutCompleteEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"layoutcomplete" Decoder LayoutCompleteEvent
layoutCompleteDecoder LayoutCompleteEvent -> model -> DOMRef -> action
action
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/list.html#snap
--
-- Callback when pagination scrolling is about to occur.
--
-- @
--
-- data Action = HandleSnap SnapEvent
--
-- view :: context -> props -> Model -> View context Action
-- view _ _ model = list_ defaultListOptions [ onSnap HandleSnap ] [ ]
--
-- update :: Action -> Effect props Model Action
-- update (HandleSnap SnapEvent {..}) =
--   io_ (consoleLog "Received SnapEvent")
--
-- @
--
onSnap :: (SnapEvent -> action) -> Attribute model action
onSnap :: forall action model.
(SnapEvent -> action) -> Attribute model action
onSnap SnapEvent -> action
action = MisoString
-> Decoder SnapEvent
-> (SnapEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"snap" Decoder SnapEvent
snapDecoder (\SnapEvent
x model
_ DOMRef
_ -> SnapEvent -> action
action SnapEvent
x)
-----------------------------------------------------------------------------
-- | Like 'onSnap', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = HandleSnap SnapEvent
--
-- view_ [ event (static (onSnapMain HandleSnap)) ] [ "some view" ]
-- @
--
onSnapMain :: (SnapEvent -> action) -> EventHandler model action
onSnapMain :: forall action model.
(SnapEvent -> action) -> EventHandler model action
onSnapMain SnapEvent -> action
action = MisoString
-> Decoder SnapEvent
-> (SnapEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"snap" Decoder SnapEvent
snapDecoder (\SnapEvent
x model
_ DOMRef
_ -> SnapEvent -> action
action SnapEvent
x)
-----------------------------------------------------------------------------
-- | Like 'onSnapMain', but the handler also receives read-only access to the
-- @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = HandleSnap SnapEvent Model DOMRef
--
-- view_ [ event (static (onSnapMainWith HandleSnap)) ] [ "some view" ]
-- @
--
onSnapMainWith :: (SnapEvent -> model -> DOMRef -> action) -> EventHandler model action
onSnapMainWith :: forall model action.
(SnapEvent -> model -> DOMRef -> action)
-> EventHandler model action
onSnapMainWith SnapEvent -> model -> DOMRef -> action
action = MisoString
-> Decoder SnapEvent
-> (SnapEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"snap" Decoder SnapEvent
snapDecoder SnapEvent -> model -> DOMRef -> action
action
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
-- | Like 'onScroll', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onScrollWith :: (ScrollEvent -> DOMRef -> action) -> Attribute model action
onScrollWith :: forall action model.
(ScrollEvent -> DOMRef -> action) -> Attribute model action
onScrollWith ScrollEvent -> DOMRef -> action
action = MisoString
-> Decoder ScrollEvent
-> (ScrollEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"scroll" Decoder ScrollEvent
scrollDecoder ((ScrollEvent -> model -> DOMRef -> action)
 -> Attribute model action)
-> (ScrollEvent -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \ScrollEvent
v model
_ DOMRef
domRef -> ScrollEvent -> DOMRef -> action
action ScrollEvent
v DOMRef
domRef
-----------------------------------------------------------------------------
-- | Like 'onScrollToUpper', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onScrollToUpperWith :: (ScrollEvent -> DOMRef -> action) -> Attribute model action
onScrollToUpperWith :: forall action model.
(ScrollEvent -> DOMRef -> action) -> Attribute model action
onScrollToUpperWith ScrollEvent -> DOMRef -> action
action = MisoString
-> Decoder ScrollEvent
-> (ScrollEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"scrolltoupper" Decoder ScrollEvent
scrollDecoder ((ScrollEvent -> model -> DOMRef -> action)
 -> Attribute model action)
-> (ScrollEvent -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \ScrollEvent
v model
_ DOMRef
domRef -> ScrollEvent -> DOMRef -> action
action ScrollEvent
v DOMRef
domRef
-----------------------------------------------------------------------------
-- | Like 'onScrollToLower', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onScrollToLowerWith :: (ScrollEvent -> DOMRef -> action) -> Attribute model action
onScrollToLowerWith :: forall action model.
(ScrollEvent -> DOMRef -> action) -> Attribute model action
onScrollToLowerWith ScrollEvent -> DOMRef -> action
action = MisoString
-> Decoder ScrollEvent
-> (ScrollEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"scrolltolower" Decoder ScrollEvent
scrollDecoder ((ScrollEvent -> model -> DOMRef -> action)
 -> Attribute model action)
-> (ScrollEvent -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \ScrollEvent
v model
_ DOMRef
domRef -> ScrollEvent -> DOMRef -> action
action ScrollEvent
v DOMRef
domRef
-----------------------------------------------------------------------------
-- | Like 'onScrollStateChange', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onScrollStateChangeWith :: (ScrollStateChange -> DOMRef -> action) -> Attribute model action
onScrollStateChangeWith :: forall action model.
(ScrollStateChange -> DOMRef -> action) -> Attribute model action
onScrollStateChangeWith ScrollStateChange -> DOMRef -> action
action = MisoString
-> Decoder ScrollStateChange
-> (ScrollStateChange -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"scrollstatechange" Decoder ScrollStateChange
scrollStateDecoder ((ScrollStateChange -> model -> DOMRef -> action)
 -> Attribute model action)
-> (ScrollStateChange -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \ScrollStateChange
v model
_ DOMRef
domRef -> ScrollStateChange -> DOMRef -> action
action ScrollStateChange
v DOMRef
domRef
-----------------------------------------------------------------------------
-- | Like 'onLayoutComplete', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onLayoutCompleteWith :: (LayoutCompleteEvent -> DOMRef -> action) -> Attribute model action
onLayoutCompleteWith :: forall action model.
(LayoutCompleteEvent -> DOMRef -> action) -> Attribute model action
onLayoutCompleteWith LayoutCompleteEvent -> DOMRef -> action
action = MisoString
-> Decoder LayoutCompleteEvent
-> (LayoutCompleteEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"layoutcomplete" Decoder LayoutCompleteEvent
layoutCompleteDecoder ((LayoutCompleteEvent -> model -> DOMRef -> action)
 -> Attribute model action)
-> (LayoutCompleteEvent -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \LayoutCompleteEvent
v model
_ DOMRef
domRef -> LayoutCompleteEvent -> DOMRef -> action
action LayoutCompleteEvent
v DOMRef
domRef
-----------------------------------------------------------------------------
-- | Like 'onSnap', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onSnapWith :: (SnapEvent -> DOMRef -> action) -> Attribute model action
onSnapWith :: forall action model.
(SnapEvent -> DOMRef -> action) -> Attribute model action
onSnapWith SnapEvent -> DOMRef -> action
action = MisoString
-> Decoder SnapEvent
-> (SnapEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"snap" Decoder SnapEvent
snapDecoder ((SnapEvent -> model -> DOMRef -> action)
 -> Attribute model action)
-> (SnapEvent -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \SnapEvent
v model
_ DOMRef
domRef -> SnapEvent -> DOMRef -> action
action SnapEvent
v DOMRef
domRef
-----------------------------------------------------------------------------