miso-lynx
Copyright(C) 2016-2025 David M. Johnson
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <code@dmj.io>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Miso.Lynx.Element.Image.Event

Description

 
Synopsis

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

data ImageLoadEvent Source #

Callback when an image_ succeeds in loading

Constructors

ImageLoadEvent 

Fields

Event Map