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

Miso.Native.Element.Image.Event

Description

 
Synopsis

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 #

Like onLoad, but the handler also receives the target element's DOMRef. Use for main-thread (MTS) handlers that imperatively mutate the element.

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 #

Like onError, but the handler also receives the target element's DOMRef. Use for main-thread (MTS) handlers that imperatively mutate the element.

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

data ImageLoadEvent Source #

Callback when an image_ succeeds in loading

Constructors

ImageLoadEvent 

Fields

Event Map