| 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 |
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.Native.Element.Image.Event
Description
Synopsis
- onLoad :: (ImageLoadEvent -> action) -> Attribute model action
- onLoadWith :: (ImageLoadEvent -> DOMRef -> action) -> Attribute model action
- onLoadMain :: (ImageLoadEvent -> action) -> EventHandler model action
- onLoadMainWith :: (ImageLoadEvent -> model -> DOMRef -> action) -> EventHandler model action
- onError :: (ImageErrorEvent -> action) -> Attribute model action
- onErrorWith :: (ImageErrorEvent -> DOMRef -> action) -> Attribute model action
- onErrorMain :: (ImageErrorEvent -> action) -> EventHandler model action
- onErrorMainWith :: (ImageErrorEvent -> model -> DOMRef -> action) -> EventHandler model action
- onStartPlay :: action -> Attribute model action
- onStartPlayWith :: (DOMRef -> action) -> Attribute model action
- onStartPlayMain :: action -> EventHandler model action
- onStartPlayMainWith :: (model -> DOMRef -> action) -> EventHandler model action
- onCurrentLoopComplete :: action -> Attribute model action
- onCurrentLoopCompleteWith :: (DOMRef -> action) -> Attribute model action
- onCurrentLoopCompleteMain :: action -> EventHandler model action
- onCurrentLoopCompleteMainWith :: (model -> DOMRef -> action) -> EventHandler model action
- onFinalLoopComplete :: action -> Attribute model action
- onFinalLoopCompleteWith :: (DOMRef -> action) -> Attribute model action
- onFinalLoopCompleteMain :: action -> EventHandler model action
- onFinalLoopCompleteMainWith :: (model -> DOMRef -> action) -> EventHandler model action
- imageLoadDecoder :: Decoder ImageLoadEvent
- imageErrorDecoder :: Decoder ImageErrorEvent
- data ImageErrorEvent = ImageErrorEvent {}
- data ImageLoadEvent = ImageLoadEvent {
- imageWidth :: Int
- imageHeight :: Int
- imageEvents :: Events
Events
onLoad :: (ImageLoadEvent -> action) -> Attribute model action Source #
https://lynxjs.org/api/elements/built-in/image.html#bindload
Triggered when the image request succeeds, outputting the image's width and height.
data Action = HandleImageLoad ImageLoadEvent
view :: context -> props -> Model -> View context Action
view model = image_ "url" [ onLoad HandleImageLoad ]
update :: Action -> Effect context props Model Action
update (HandleImageLoad ImageLoadEvent {..}) = do
io_ (consoleLog "image load event received")
onLoadWith :: (ImageLoadEvent -> DOMRef -> action) -> Attribute model action Source #
onLoadMain :: (ImageLoadEvent -> action) -> EventHandler model action Source #
Like onLoad, but dispatched on the Lynx main thread (MTS).
Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-XStaticPointers.
data Action = HandleImageLoad ImageLoadEvent view_ [ event (static (onLoadMain HandleImageLoad)) ] [ "some view" ]
onLoadMainWith :: (ImageLoadEvent -> model -> DOMRef -> action) -> EventHandler model action Source #
Like onLoadMain, but the handler also receives read-only access to the
model and the target element's DOMRef (for imperative MTS mutation).
data Action = HandleImageLoad ImageLoadEvent Model DOMRef view_ [ event (static (onLoadMainWith HandleImageLoad)) ] [ "some view" ]
onError :: (ImageErrorEvent -> action) -> Attribute model action Source #
https://lynxjs.org/api/elements/built-in/image.html#binderror
Triggered when the image request fails, outputting the error message and code.
data Action = HandleImageError ImageErrorEvent
view :: context -> props -> Model -> View context Action
view _ _ model = image_ "url" [ onError HandleImageError ]
update :: Action -> Effect context props Model Action
update (HandleImageError ImageErrorEvent {..}) = do
io_ (consoleLog "image error event received")
onErrorWith :: (ImageErrorEvent -> DOMRef -> action) -> Attribute model action Source #
onErrorMain :: (ImageErrorEvent -> action) -> EventHandler model action Source #
Like onError, but dispatched on the Lynx main thread (MTS).
Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-XStaticPointers.
data Action = HandleImageError ImageErrorEvent view_ [ event (static (onErrorMain HandleImageError)) ] [ "some view" ]
onErrorMainWith :: (ImageErrorEvent -> model -> DOMRef -> action) -> EventHandler model action Source #
Like onErrorMain, but the handler also receives read-only access to the
model and the target element's DOMRef (for imperative MTS mutation).
data Action = HandleImageError ImageErrorEvent Model DOMRef view_ [ event (static (onErrorMainWith HandleImageError)) ] [ "some view" ]
onStartPlay :: action -> Attribute model action Source #
https://lynxjs.org/api/elements/built-in/image.html#bindstartplay
Triggered when the animated image starts playing.
data Action = HandleStartPlay view :: context -> props -> Model -> View context Action view _ _ model = image_ "url" [ onStartPlay HandleStartPlay ]
onStartPlayWith :: (DOMRef -> action) -> Attribute model action Source #
Like onStartPlay, but the handler also receives the target element's DOMRef.
Use for main-thread (MTS) handlers that imperatively mutate the element.
onStartPlayMain :: action -> EventHandler model action Source #
Like onStartPlay, but dispatched on the Lynx main thread (MTS).
Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-XStaticPointers.
data Action = HandleStartPlay view_ [ event (static (onStartPlayMain HandleStartPlay)) ] [ "some view" ]
onStartPlayMainWith :: (model -> DOMRef -> action) -> EventHandler model action Source #
Like onStartPlayMain, but the handler also receives read-only access to
the model and the target element's DOMRef (for imperative MTS mutation).
data Action = HandleStartPlay Model DOMRef view_ [ event (static (onStartPlayMainWith HandleStartPlay)) ] [ "some view" ]
onCurrentLoopComplete :: action -> Attribute model action Source #
https://lynxjs.org/api/elements/built-in/image.html#bindcurrentloopcomplete
Triggered when one loop of the animated image finishes playing.
data Action = HandleCurrentLoopComplete view :: context -> props -> Model -> View context Action view _ _ model = image_ "url" [ onCurrentLoopComplete HandleCurrentLoopComplete ]
onCurrentLoopCompleteWith :: (DOMRef -> action) -> Attribute model action Source #
Like onCurrentLoopComplete, but the handler also receives the target element's DOMRef.
Use for main-thread (MTS) handlers that imperatively mutate the element.
onCurrentLoopCompleteMain :: action -> EventHandler model action Source #
Like onCurrentLoopComplete, but dispatched on the Lynx main thread (MTS).
Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-XStaticPointers.
data Action = HandleCurrentLoopComplete view_ [ event (static (onCurrentLoopCompleteMain HandleCurrentLoopComplete)) ] [ "some view" ]
onCurrentLoopCompleteMainWith :: (model -> DOMRef -> action) -> EventHandler model action Source #
Like onCurrentLoopCompleteMain, but the handler also receives read-only
access to the model and the target element's DOMRef (for imperative MTS
mutation).
data Action = HandleCurrentLoopComplete Model DOMRef view_ [ event (static (onCurrentLoopCompleteMainWith HandleCurrentLoopComplete)) ] [ "some view" ]
onFinalLoopComplete :: action -> Attribute model action Source #
https://lynxjs.org/api/elements/built-in/image.html#bindfinalloopcomplete
Triggered when the animated image finishes playing all loopCount_ loops.
data Action = HandleFinalLoopComplete view :: context -> props -> Model -> View context Action view _ _ model = image_ "url" [ onFinalLoopComplete HandleFinalLoopComplete ]
onFinalLoopCompleteWith :: (DOMRef -> action) -> Attribute model action Source #
Like onFinalLoopComplete, but the handler also receives the target element's DOMRef.
Use for main-thread (MTS) handlers that imperatively mutate the element.
onFinalLoopCompleteMain :: action -> EventHandler model action Source #
Like onFinalLoopComplete, but dispatched on the Lynx main thread (MTS).
Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-XStaticPointers.
data Action = HandleFinalLoopComplete view_ [ event (static (onFinalLoopCompleteMain HandleFinalLoopComplete)) ] [ "some view" ]
onFinalLoopCompleteMainWith :: (model -> DOMRef -> action) -> EventHandler model action Source #
Like onFinalLoopCompleteMain, but the handler also receives read-only
access to the model and the target element's DOMRef (for imperative MTS
mutation).
data Action = HandleFinalLoopComplete Model DOMRef view_ [ event (static (onFinalLoopCompleteMainWith HandleFinalLoopComplete)) ] [ "some view" ]
Decoder
Types
data ImageErrorEvent Source #
Callback when an image_ fails to load
Constructors
| ImageErrorEvent | |
Fields
| |
Instances
| Show ImageErrorEvent Source # | |
Defined in Miso.Native.Element.Image.Event Methods showsPrec :: Int -> ImageErrorEvent -> ShowS # show :: ImageErrorEvent -> String # showList :: [ImageErrorEvent] -> ShowS # | |
| Eq ImageErrorEvent Source # | |
Defined in Miso.Native.Element.Image.Event Methods (==) :: ImageErrorEvent -> ImageErrorEvent -> Bool # (/=) :: ImageErrorEvent -> ImageErrorEvent -> Bool # | |
data ImageLoadEvent Source #
Callback when an image_ succeeds in loading
Constructors
| ImageLoadEvent | |
Fields
| |
Instances
| Show ImageLoadEvent Source # | |
Defined in Miso.Native.Element.Image.Event Methods showsPrec :: Int -> ImageLoadEvent -> ShowS # show :: ImageLoadEvent -> String # showList :: [ImageLoadEvent] -> ShowS # | |
| Eq ImageLoadEvent Source # | |
Defined in Miso.Native.Element.Image.Event Methods (==) :: ImageLoadEvent -> ImageLoadEvent -> Bool # (/=) :: ImageLoadEvent -> ImageLoadEvent -> Bool # | |
Event Map
imageEvents :: Events Source #