| Copyright | (C) 2016-2025 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.Lynx.Element.Image.Event
Description
Synopsis
- onLoad :: (ImageLoadEvent -> action) -> Attribute action
- onError :: (ImageErrorEvent -> action) -> Attribute action
- imageLoadDecoder :: Decoder ImageLoadEvent
- imageErrorDecoder :: Decoder ImageErrorEvent
- data ImageErrorEvent = ImageErrorEvent {}
- data ImageLoadEvent = ImageLoadEvent {
- imageWidth :: Int
- imageHeight :: Int
- imageEvents :: Events
Events
onLoad :: (ImageLoadEvent -> action) -> Attribute 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 :: Model -> View Action
view model = image_ "url" [ onLoad HandleImageLoad ]
update :: Action -> Effect Model Action
update (HandleImageLoad ImageLoadEvent {..}) = do
io_ (consoleLog "image load event received")
onError :: (ImageErrorEvent -> action) -> Attribute 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 :: Model -> View Action
view model = image_ "url" [ onError HandleImageError ]
update :: Action -> Effect Model Action
update (HandleImageError ImageErrorEvent {..}) = do
io_ (consoleLog "image error event received")
Decoder
Types
data ImageErrorEvent Source #
Callback when an image_ fails to load
Constructors
| ImageErrorEvent | |
Fields
| |
Instances
| Show ImageErrorEvent Source # | |
Defined in Miso.Lynx.Element.Image.Event Methods showsPrec :: Int -> ImageErrorEvent -> ShowS # show :: ImageErrorEvent -> String # showList :: [ImageErrorEvent] -> ShowS # | |
| Eq ImageErrorEvent Source # | |
Defined in Miso.Lynx.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.Lynx.Element.Image.Event Methods showsPrec :: Int -> ImageLoadEvent -> ShowS # show :: ImageLoadEvent -> String # showList :: [ImageLoadEvent] -> ShowS # | |
| Eq ImageLoadEvent Source # | |
Defined in Miso.Lynx.Element.Image.Event Methods (==) :: ImageLoadEvent -> ImageLoadEvent -> Bool # (/=) :: ImageLoadEvent -> ImageLoadEvent -> Bool # | |
Event Map
imageEvents :: Events Source #