packages feed

jsaddle-dom-0.10.0.0: src/JSDOM/Generated/DeviceMotionEvent.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from orientation-event (webref). Do not edit.
module JSDOM.Generated.DeviceMotionEvent
       (newDeviceMotionEvent, getAcceleration, getAccelerationUnsafe, getAccelerationUnchecked, getAccelerationIncludingGravity, getAccelerationIncludingGravityUnsafe, getAccelerationIncludingGravityUnchecked, getRotationRate, getRotationRateUnsafe, getRotationRateUnchecked, getInterval, DeviceMotionEvent(..), gTypeDeviceMotionEvent)
       where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums

-- | <https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/DeviceMotionEvent MDN DeviceMotionEvent. documentation>
newDeviceMotionEvent :: (MonadDOM m, ToJSString type') => type' -> Maybe DeviceMotionEventInit -> m DeviceMotionEvent
newDeviceMotionEvent type' eventInitDict = liftDOM (((new (jsg "DeviceMotionEvent") [toJSVal type', P.maybe (P.return jsUndefined) toJSVal eventInitDict]) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/acceleration MDN DeviceMotionEvent.acceleration documentation>
getAcceleration :: (MonadDOM m) => DeviceMotionEvent -> m (Maybe DeviceMotionEventAcceleration)
getAcceleration self = liftDOM (((self ^. js "acceleration") >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/acceleration MDN DeviceMotionEvent.acceleration documentation>
getAccelerationUnsafe :: (MonadDOM m, HasCallStack) => DeviceMotionEvent -> m DeviceMotionEventAcceleration
getAccelerationUnsafe self = liftDOM ((((self ^. js "acceleration") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/acceleration MDN DeviceMotionEvent.acceleration documentation>
getAccelerationUnchecked :: (MonadDOM m) => DeviceMotionEvent -> m DeviceMotionEventAcceleration
getAccelerationUnchecked self = liftDOM (((self ^. js "acceleration") >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/accelerationIncludingGravity MDN DeviceMotionEvent.accelerationIncludingGravity documentation>
getAccelerationIncludingGravity :: (MonadDOM m) => DeviceMotionEvent -> m (Maybe DeviceMotionEventAcceleration)
getAccelerationIncludingGravity self = liftDOM (((self ^. js "accelerationIncludingGravity") >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/accelerationIncludingGravity MDN DeviceMotionEvent.accelerationIncludingGravity documentation>
getAccelerationIncludingGravityUnsafe :: (MonadDOM m, HasCallStack) => DeviceMotionEvent -> m DeviceMotionEventAcceleration
getAccelerationIncludingGravityUnsafe self = liftDOM ((((self ^. js "accelerationIncludingGravity") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/accelerationIncludingGravity MDN DeviceMotionEvent.accelerationIncludingGravity documentation>
getAccelerationIncludingGravityUnchecked :: (MonadDOM m) => DeviceMotionEvent -> m DeviceMotionEventAcceleration
getAccelerationIncludingGravityUnchecked self = liftDOM (((self ^. js "accelerationIncludingGravity") >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/rotationRate MDN DeviceMotionEvent.rotationRate documentation>
getRotationRate :: (MonadDOM m) => DeviceMotionEvent -> m (Maybe DeviceMotionEventRotationRate)
getRotationRate self = liftDOM (((self ^. js "rotationRate") >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/rotationRate MDN DeviceMotionEvent.rotationRate documentation>
getRotationRateUnsafe :: (MonadDOM m, HasCallStack) => DeviceMotionEvent -> m DeviceMotionEventRotationRate
getRotationRateUnsafe self = liftDOM ((((self ^. js "rotationRate") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/rotationRate MDN DeviceMotionEvent.rotationRate documentation>
getRotationRateUnchecked :: (MonadDOM m) => DeviceMotionEvent -> m DeviceMotionEventRotationRate
getRotationRateUnchecked self = liftDOM (((self ^. js "rotationRate") >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/DeviceMotionEvent/interval MDN DeviceMotionEvent.interval documentation>
getInterval :: (MonadDOM m) => DeviceMotionEvent -> m Double
getInterval self = liftDOM (((self ^. js "interval") >>= valToNumber))