jsaddle-dom-0.10.0.0: src/JSDOM/Generated/ScreenOrientation.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from screen-orientation (webref). Do not edit.
module JSDOM.Generated.ScreenOrientation
(lock, unlock, getType, getAngle, change, ScreenOrientation(..), gTypeScreenOrientation)
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/ScreenOrientation/lock MDN ScreenOrientation.lock documentation>
lock :: (MonadDOM m) => ScreenOrientation -> OrientationLockType -> m ()
lock self orientation = liftDOM (void (((self ^. jsf "lock" [toJSVal orientation]) >>= readPromise)))
-- | <https://developer.mozilla.org/docs/Web/API/ScreenOrientation/unlock MDN ScreenOrientation.unlock documentation>
unlock :: (MonadDOM m) => ScreenOrientation -> m ()
unlock self = liftDOM (void (self ^. jsf "unlock" ()))
-- | <https://developer.mozilla.org/docs/Web/API/ScreenOrientation/type MDN ScreenOrientation.type documentation>
getType :: (MonadDOM m) => ScreenOrientation -> m OrientationType
getType self = liftDOM (((self ^. js "type") >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/ScreenOrientation/angle MDN ScreenOrientation.angle documentation>
getAngle :: (MonadDOM m) => ScreenOrientation -> m Word
getAngle self = liftDOM ((P.round <$> ((self ^. js "angle") >>= valToNumber)))
-- | <https://w3c.github.io/screen-orientation/#dom-screenorientation-onchange change event>
change :: EventName ScreenOrientation Event
change = unsafeEventName (toJSString "change")