-----------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Miso.Lynx.Element.Image.Method
-- 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
----------------------------------------------------------------------------
module Miso.Lynx.Element.Image.Method
  ( -- *** Methods
    startAnimation
  , pauseAnimation
  , stopAnimation
  , resumeAnimation
  ) where
-----------------------------------------------------------------------------
import           Miso
import           Miso.Lynx.FFI (invokeExec)
-----------------------------------------------------------------------------
-- | <https://lynxjs.org/api/elements/built-in/image.html#startanimate>
--
-- Starts an animation at the ID selected
--
-- > startAnimation "someImageId" AnimationStarted AnimationError
--
startAnimation
  :: MisoString
  -> action
  -> (MisoString -> action)
  -> Effect parent model action
startAnimation selector action =
  invokeExec "startAnimate" selector () (\() -> action)
-----------------------------------------------------------------------------
-- | <https://lynxjs.org/api/elements/built-in/image.html#pauseanimation>
--
-- Pauses an animation at the ID selected
--
-- > pauseAnimation "someImageId" AnimationPauseed AnimationError
--
pauseAnimation
  :: MisoString
  -> action
  -> (MisoString -> action)
  -> Effect parent model action
pauseAnimation selector action =
  invokeExec "pauseAnimation" selector () (\() -> action)
-----------------------------------------------------------------------------
-- | <https://lynxjs.org/api/elements/built-in/image.html#resumeanimation>
--
-- Resumes an animation at the ID selected
--
-- > resumeAnimation "someImageId" AnimationResumeed AnimationError
--
resumeAnimation
  :: MisoString
  -> action
  -> (MisoString -> action)
  -> Effect parent model action
resumeAnimation selector action =
  invokeExec "resumeAnimation" selector () (\() -> action)
-----------------------------------------------------------------------------
-- | <https://lynxjs.org/api/elements/built-in/image.html#stopanimation>
--
-- Stops an animation at the ID selected
--
-- > stopAnimation "someImageId" AnimationStoped AnimationError
--
stopAnimation
  :: MisoString
  -> action
  -> (MisoString -> action)
  -> Effect parent model action
stopAnimation selector action =
  invokeExec "stopAnimation" selector () (\() -> action)
-----------------------------------------------------------------------------
