packages feed

ghcjs-dom-javascript-0.10.0.0: src/GHCJS/DOM/JSFFI/Generated/Animation.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from web-animations-1 (webref). Do not edit.
module GHCJS.DOM.JSFFI.Generated.Animation
       (js_newAnimation, js_cancel, js_commitStyles, js_finish, js_pause, js_persist, js_play, js_reverse, js_updatePlaybackRate, js_setId, js_getId, js_setEffect, js_getEffect, js_setTimeline, js_getTimeline, js_setPlaybackRate, js_getPlaybackRate, js_getPlayState, js_getReplaceState, js_getPending, js_getReady, js_getFinished, js_setStartTime, js_getStartTime, js_setCurrentTime, js_getCurrentTime, js_getOverallProgress, newAnimation, cancel, commitStyles, finish, pause, persist, play, reverse, updatePlaybackRate, setId, getId, setEffect, getEffect, getEffectUnsafe, getEffectUnchecked, setTimeline, getTimeline, getTimelineUnsafe, getTimelineUnchecked, setPlaybackRate, getPlaybackRate, getPlayState, getReplaceState, getPending, getReady, getFinished, setStartTime, getStartTime, getStartTimeUnsafe, getStartTimeUnchecked, setCurrentTime, getCurrentTime, getCurrentTimeUnsafe, getCurrentTimeUnchecked, getOverallProgress, getOverallProgressUnsafe, getOverallProgressUnchecked, finishEvent, cancelEvent, remove, Animation(..), gTypeAnimation, IsAnimation, toAnimation)
       where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import GHCJS.Types (JSVal, JSString)
import GHCJS.Foreign (jsUndefined, jsNull)
import GHCJS.DOM.Types
import qualified GHCJS.DOM.Types as Types
import GHCJS.DOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import GHCJS.DOM.JSFFI.Generated.Enums

foreign import javascript safe "(($1, $2) => { return new globalThis[\"Animation\"]($1, $2); })"
        js_newAnimation :: JSVal -> JSVal -> IO Animation
-- | <https://developer.mozilla.org/docs/Web/API/Animation/Animation MDN Animation. documentation>
newAnimation :: (MonadDOM m, IsAnimationEffect effect, IsAnimationTimeline timeline) => Maybe effect -> Maybe timeline -> m Animation
newAnimation effect timeline = liftDOM (((toJSVal effect) >>= \a1' -> (toJSVal timeline) >>= \a2' -> js_newAnimation a1' a2'))

foreign import javascript safe "(($1) => { return $1[\"cancel\"](); })"
        js_cancel :: Animation -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/Animation/cancel MDN Animation.cancel documentation>
cancel :: (MonadDOM m, IsAnimation self) => self -> m ()
cancel self = liftDOM (void ((js_cancel ((Types.toAnimation self)))))

foreign import javascript safe "(($1) => { return $1[\"commitStyles\"](); })"
        js_commitStyles :: Animation -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/Animation/commitStyles MDN Animation.commitStyles documentation>
commitStyles :: (MonadDOM m, IsAnimation self) => self -> m ()
commitStyles self = liftDOM (void ((js_commitStyles ((Types.toAnimation self)))))

foreign import javascript safe "(($1) => { return $1[\"finish\"](); })"
        js_finish :: Animation -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/Animation/finish MDN Animation.finish documentation>
finish :: (MonadDOM m, IsAnimation self) => self -> m ()
finish self = liftDOM (void ((js_finish ((Types.toAnimation self)))))

foreign import javascript safe "(($1) => { return $1[\"pause\"](); })"
        js_pause :: Animation -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/Animation/pause MDN Animation.pause documentation>
pause :: (MonadDOM m, IsAnimation self) => self -> m ()
pause self = liftDOM (void ((js_pause ((Types.toAnimation self)))))

foreign import javascript safe "(($1) => { return $1[\"persist\"](); })"
        js_persist :: Animation -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/Animation/persist MDN Animation.persist documentation>
persist :: (MonadDOM m, IsAnimation self) => self -> m ()
persist self = liftDOM (void ((js_persist ((Types.toAnimation self)))))

foreign import javascript safe "(($1) => { return $1[\"play\"](); })"
        js_play :: Animation -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/Animation/play MDN Animation.play documentation>
play :: (MonadDOM m, IsAnimation self) => self -> m ()
play self = liftDOM (void ((js_play ((Types.toAnimation self)))))

foreign import javascript safe "(($1) => { return $1[\"reverse\"](); })"
        js_reverse :: Animation -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/Animation/reverse MDN Animation.reverse documentation>
reverse :: (MonadDOM m, IsAnimation self) => self -> m ()
reverse self = liftDOM (void ((js_reverse ((Types.toAnimation self)))))

foreign import javascript safe "(($1, $2) => { return $1[\"updatePlaybackRate\"]($2); })"
        js_updatePlaybackRate :: Animation -> Double -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/Animation/updatePlaybackRate MDN Animation.updatePlaybackRate documentation>
updatePlaybackRate :: (MonadDOM m, IsAnimation self) => self -> Double -> m ()
updatePlaybackRate self playbackRate = liftDOM (void ((js_updatePlaybackRate ((Types.toAnimation self)) (playbackRate))))

foreign import javascript safe "(($1, $2) => { $1[\"id\"] = $2; })"
        js_setId :: Animation -> JSString -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/Animation/id MDN Animation.id documentation>
setId :: (MonadDOM m, IsAnimation self, ToJSString val) => self -> val -> m ()
setId self val = liftDOM (void ((js_setId ((Types.toAnimation self)) (toJSString val))))

foreign import javascript unsafe "(($1) => { return $1[\"id\"]; })"
        js_getId :: Animation -> IO JSString
-- | <https://developer.mozilla.org/docs/Web/API/Animation/id MDN Animation.id documentation>
getId :: (MonadDOM m, IsAnimation self, FromJSString result) => self -> m result
getId self = liftDOM ((fromJSString <$> (js_getId ((Types.toAnimation self)))))

foreign import javascript safe "(($1, $2) => { $1[\"effect\"] = $2; })"
        js_setEffect :: Animation -> JSVal -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/Animation/effect MDN Animation.effect documentation>
setEffect :: (MonadDOM m, IsAnimation self, IsAnimationEffect val) => self -> Maybe val -> m ()
setEffect self val = liftDOM (void (((toJSVal val) >>= \a2' -> js_setEffect ((Types.toAnimation self)) a2')))

foreign import javascript unsafe "(($1) => { return $1[\"effect\"]; })"
        js_getEffect :: Animation -> IO JSVal
-- | <https://developer.mozilla.org/docs/Web/API/Animation/effect MDN Animation.effect documentation>
getEffect :: (MonadDOM m, IsAnimation self) => self -> m (Maybe AnimationEffect)
getEffect self = liftDOM (((js_getEffect ((Types.toAnimation self))) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/Animation/effect MDN Animation.effect documentation>
getEffectUnsafe :: (MonadDOM m, IsAnimation self, HasCallStack) => self -> m AnimationEffect
getEffectUnsafe self = liftDOM ((((js_getEffect ((Types.toAnimation self))) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://developer.mozilla.org/docs/Web/API/Animation/effect MDN Animation.effect documentation>
getEffectUnchecked :: (MonadDOM m, IsAnimation self) => self -> m AnimationEffect
getEffectUnchecked self = liftDOM ((pFromJSVal <$> (js_getEffect ((Types.toAnimation self)))))

foreign import javascript safe "(($1, $2) => { $1[\"timeline\"] = $2; })"
        js_setTimeline :: Animation -> JSVal -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/Animation/timeline MDN Animation.timeline documentation>
setTimeline :: (MonadDOM m, IsAnimation self, IsAnimationTimeline val) => self -> Maybe val -> m ()
setTimeline self val = liftDOM (void (((toJSVal val) >>= \a2' -> js_setTimeline ((Types.toAnimation self)) a2')))

foreign import javascript unsafe "(($1) => { return $1[\"timeline\"]; })"
        js_getTimeline :: Animation -> IO JSVal
-- | <https://developer.mozilla.org/docs/Web/API/Animation/timeline MDN Animation.timeline documentation>
getTimeline :: (MonadDOM m, IsAnimation self) => self -> m (Maybe AnimationTimeline)
getTimeline self = liftDOM (((js_getTimeline ((Types.toAnimation self))) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/Animation/timeline MDN Animation.timeline documentation>
getTimelineUnsafe :: (MonadDOM m, IsAnimation self, HasCallStack) => self -> m AnimationTimeline
getTimelineUnsafe self = liftDOM ((((js_getTimeline ((Types.toAnimation self))) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://developer.mozilla.org/docs/Web/API/Animation/timeline MDN Animation.timeline documentation>
getTimelineUnchecked :: (MonadDOM m, IsAnimation self) => self -> m AnimationTimeline
getTimelineUnchecked self = liftDOM ((pFromJSVal <$> (js_getTimeline ((Types.toAnimation self)))))

foreign import javascript safe "(($1, $2) => { $1[\"playbackRate\"] = $2; })"
        js_setPlaybackRate :: Animation -> Double -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/Animation/playbackRate MDN Animation.playbackRate documentation>
setPlaybackRate :: (MonadDOM m, IsAnimation self) => self -> Double -> m ()
setPlaybackRate self val = liftDOM (void ((js_setPlaybackRate ((Types.toAnimation self)) (val))))

foreign import javascript unsafe "(($1) => { return $1[\"playbackRate\"]; })"
        js_getPlaybackRate :: Animation -> IO Double
-- | <https://developer.mozilla.org/docs/Web/API/Animation/playbackRate MDN Animation.playbackRate documentation>
getPlaybackRate :: (MonadDOM m, IsAnimation self) => self -> m Double
getPlaybackRate self = liftDOM ((js_getPlaybackRate ((Types.toAnimation self))))

foreign import javascript unsafe "(($1) => { return $1[\"playState\"]; })"
        js_getPlayState :: Animation -> IO JSVal
-- | <https://developer.mozilla.org/docs/Web/API/Animation/playState MDN Animation.playState documentation>
getPlayState :: (MonadDOM m, IsAnimation self) => self -> m AnimationPlayState
getPlayState self = liftDOM (((js_getPlayState ((Types.toAnimation self))) >>= fromJSValUnchecked))

foreign import javascript unsafe "(($1) => { return $1[\"replaceState\"]; })"
        js_getReplaceState :: Animation -> IO JSVal
-- | <https://developer.mozilla.org/docs/Web/API/Animation/replaceState MDN Animation.replaceState documentation>
getReplaceState :: (MonadDOM m, IsAnimation self) => self -> m AnimationReplaceState
getReplaceState self = liftDOM (((js_getReplaceState ((Types.toAnimation self))) >>= fromJSValUnchecked))

foreign import javascript unsafe "(($1) => { return $1[\"pending\"]; })"
        js_getPending :: Animation -> IO Bool
-- | <https://developer.mozilla.org/docs/Web/API/Animation/pending MDN Animation.pending documentation>
getPending :: (MonadDOM m, IsAnimation self) => self -> m Bool
getPending self = liftDOM ((js_getPending ((Types.toAnimation self))))

foreign import javascript interruptible "(($1, $c) => { return $1[\"ready\"].then(function(s) { $c(null, s);}, function(e) { $c(e, null);}); })"
        js_getReady :: Animation -> IO (JSVal, Animation)
-- | <https://developer.mozilla.org/docs/Web/API/Animation/ready MDN Animation.ready documentation>
getReady :: (MonadDOM m, IsAnimation self) => self -> m Animation
getReady self = liftDOM (((js_getReady ((Types.toAnimation self))) >>= checkPromiseResult))

foreign import javascript interruptible "(($1, $c) => { return $1[\"finished\"].then(function(s) { $c(null, s);}, function(e) { $c(e, null);}); })"
        js_getFinished :: Animation -> IO (JSVal, Animation)
-- | <https://developer.mozilla.org/docs/Web/API/Animation/finished MDN Animation.finished documentation>
getFinished :: (MonadDOM m, IsAnimation self) => self -> m Animation
getFinished self = liftDOM (((js_getFinished ((Types.toAnimation self))) >>= checkPromiseResult))

foreign import javascript safe "(($1, $2) => { $1[\"startTime\"] = $2; })"
        js_setStartTime :: Animation -> JSVal -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/Animation/startTime MDN Animation.startTime documentation>
setStartTime :: (MonadDOM m, IsAnimation self, IsCSSNumberish val) => self -> Maybe val -> m ()
setStartTime self val = liftDOM (void (((toJSVal val) >>= \a2' -> js_setStartTime ((Types.toAnimation self)) a2')))

foreign import javascript unsafe "(($1) => { return $1[\"startTime\"]; })"
        js_getStartTime :: Animation -> IO JSVal
-- | <https://developer.mozilla.org/docs/Web/API/Animation/startTime MDN Animation.startTime documentation>
getStartTime :: (MonadDOM m, IsAnimation self) => self -> m (Maybe CSSNumberish)
getStartTime self = liftDOM (((js_getStartTime ((Types.toAnimation self))) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/Animation/startTime MDN Animation.startTime documentation>
getStartTimeUnsafe :: (MonadDOM m, IsAnimation self, HasCallStack) => self -> m CSSNumberish
getStartTimeUnsafe self = liftDOM ((((js_getStartTime ((Types.toAnimation self))) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://developer.mozilla.org/docs/Web/API/Animation/startTime MDN Animation.startTime documentation>
getStartTimeUnchecked :: (MonadDOM m, IsAnimation self) => self -> m CSSNumberish
getStartTimeUnchecked self = liftDOM ((pFromJSVal <$> (js_getStartTime ((Types.toAnimation self)))))

foreign import javascript safe "(($1, $2) => { $1[\"currentTime\"] = $2; })"
        js_setCurrentTime :: Animation -> JSVal -> IO ()
-- | <https://developer.mozilla.org/docs/Web/API/Animation/currentTime MDN Animation.currentTime documentation>
setCurrentTime :: (MonadDOM m, IsAnimation self, IsCSSNumberish val) => self -> Maybe val -> m ()
setCurrentTime self val = liftDOM (void (((toJSVal val) >>= \a2' -> js_setCurrentTime ((Types.toAnimation self)) a2')))

foreign import javascript unsafe "(($1) => { return $1[\"currentTime\"]; })"
        js_getCurrentTime :: Animation -> IO JSVal
-- | <https://developer.mozilla.org/docs/Web/API/Animation/currentTime MDN Animation.currentTime documentation>
getCurrentTime :: (MonadDOM m, IsAnimation self) => self -> m (Maybe CSSNumberish)
getCurrentTime self = liftDOM (((js_getCurrentTime ((Types.toAnimation self))) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/Animation/currentTime MDN Animation.currentTime documentation>
getCurrentTimeUnsafe :: (MonadDOM m, IsAnimation self, HasCallStack) => self -> m CSSNumberish
getCurrentTimeUnsafe self = liftDOM ((((js_getCurrentTime ((Types.toAnimation self))) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://developer.mozilla.org/docs/Web/API/Animation/currentTime MDN Animation.currentTime documentation>
getCurrentTimeUnchecked :: (MonadDOM m, IsAnimation self) => self -> m CSSNumberish
getCurrentTimeUnchecked self = liftDOM ((pFromJSVal <$> (js_getCurrentTime ((Types.toAnimation self)))))

foreign import javascript unsafe "(($1) => { return $1[\"overallProgress\"]; })"
        js_getOverallProgress :: Animation -> IO JSVal
-- | <https://developer.mozilla.org/docs/Web/API/Animation/overallProgress MDN Animation.overallProgress documentation>
getOverallProgress :: (MonadDOM m, IsAnimation self) => self -> m (Maybe Double)
getOverallProgress self = liftDOM (((js_getOverallProgress ((Types.toAnimation self))) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/Animation/overallProgress MDN Animation.overallProgress documentation>
getOverallProgressUnsafe :: (MonadDOM m, IsAnimation self, HasCallStack) => self -> m Double
getOverallProgressUnsafe self = liftDOM ((((js_getOverallProgress ((Types.toAnimation self))) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://developer.mozilla.org/docs/Web/API/Animation/overallProgress MDN Animation.overallProgress documentation>
getOverallProgressUnchecked :: (MonadDOM m, IsAnimation self) => self -> m Double
getOverallProgressUnchecked self = liftDOM ((pFromJSVal <$> (js_getOverallProgress ((Types.toAnimation self)))))

-- | <https://drafts.csswg.org/web-animations-1/#dom-animation-onfinish finish event>
finishEvent :: (IsAnimation self, IsEventTarget self) => EventName self AnimationPlaybackEvent
finishEvent = unsafeEventName (toJSString "finish")

-- | <https://drafts.csswg.org/web-animations-1/#dom-animation-oncancel cancel event>
cancelEvent :: (IsAnimation self, IsEventTarget self) => EventName self AnimationPlaybackEvent
cancelEvent = unsafeEventName (toJSString "cancel")

-- | <https://drafts.csswg.org/web-animations-1/#dom-animation-onremove remove event>
remove :: (IsAnimation self, IsEventTarget self) => EventName self AnimationPlaybackEvent
remove = unsafeEventName (toJSString "remove")