{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.IntersectionObserver
(newIntersectionObserver, observe, unobserve, disconnect,
takeRecords, takeRecords_, getRoot, getRootUnsafe,
getRootUnchecked, getRootMargin, getThresholds,
IntersectionObserver(..), gTypeIntersectionObserver)
where
import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, realToFrac, fmap, Show, Read, Eq, Ord, Maybe(..))
import qualified Prelude (error)
import Data.Typeable (Typeable)
import Data.Traversable (mapM)
import Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, asyncFunction, new, array, jsUndefined, (!), (!!))
import Data.Int (Int64)
import Data.Word (Word, Word64)
import JSDOM.Types
import Control.Applicative ((<$>))
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Enums
newIntersectionObserver ::
(MonadDOM m) =>
IntersectionObserverCallback ->
Maybe IntersectionObserverInit -> m IntersectionObserver
newIntersectionObserver :: forall (m :: * -> *).
MonadDOM m =>
IntersectionObserverCallback
-> Maybe IntersectionObserverInit -> m IntersectionObserver
newIntersectionObserver IntersectionObserverCallback
callback Maybe IntersectionObserverInit
options
= DOM IntersectionObserver -> m IntersectionObserver
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
(JSVal -> IntersectionObserver
IntersectionObserver (JSVal -> IntersectionObserver)
-> JSM JSVal -> DOM IntersectionObserver
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
JSM JSVal -> [JSM JSVal] -> JSM JSVal
forall constructor args.
(MakeObject constructor, MakeArgs args) =>
constructor -> args -> JSM JSVal
new (String -> JSM JSVal
forall a. ToJSString a => a -> JSM JSVal
jsg String
"IntersectionObserver")
[IntersectionObserverCallback -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal IntersectionObserverCallback
callback, Maybe IntersectionObserverInit -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe IntersectionObserverInit
options])
observe ::
(MonadDOM m, IsElement target) =>
IntersectionObserver -> target -> m ()
observe :: forall (m :: * -> *) target.
(MonadDOM m, IsElement target) =>
IntersectionObserver -> target -> m ()
observe IntersectionObserver
self target
target
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IntersectionObserver
self IntersectionObserver
-> Getting (JSM JSVal) IntersectionObserver (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"observe" [target -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal target
target]))
unobserve ::
(MonadDOM m, IsElement target) =>
IntersectionObserver -> target -> m ()
unobserve :: forall (m :: * -> *) target.
(MonadDOM m, IsElement target) =>
IntersectionObserver -> target -> m ()
unobserve IntersectionObserver
self target
target
= DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IntersectionObserver
self IntersectionObserver
-> Getting (JSM JSVal) IntersectionObserver (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"unobserve" [target -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal target
target]))
disconnect :: (MonadDOM m) => IntersectionObserver -> m ()
disconnect :: forall (m :: * -> *). MonadDOM m => IntersectionObserver -> m ()
disconnect IntersectionObserver
self = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IntersectionObserver
self IntersectionObserver
-> Getting (JSM JSVal) IntersectionObserver (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> () -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"disconnect" ()))
takeRecords ::
(MonadDOM m) =>
IntersectionObserver -> m [IntersectionObserverEntry]
takeRecords :: forall (m :: * -> *).
MonadDOM m =>
IntersectionObserver -> m [IntersectionObserverEntry]
takeRecords IntersectionObserver
self
= DOM [IntersectionObserverEntry] -> m [IntersectionObserverEntry]
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((IntersectionObserver
self IntersectionObserver
-> Getting (JSM JSVal) IntersectionObserver (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> () -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"takeRecords" ()) JSM JSVal
-> (JSVal -> DOM [IntersectionObserverEntry])
-> DOM [IntersectionObserverEntry]
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM [IntersectionObserverEntry]
forall o. FromJSVal o => JSVal -> JSM [o]
fromJSArrayUnchecked)
takeRecords_ :: (MonadDOM m) => IntersectionObserver -> m ()
takeRecords_ :: forall (m :: * -> *). MonadDOM m => IntersectionObserver -> m ()
takeRecords_ IntersectionObserver
self = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IntersectionObserver
self IntersectionObserver
-> Getting (JSM JSVal) IntersectionObserver (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> () -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"takeRecords" ()))
getRoot ::
(MonadDOM m) => IntersectionObserver -> m (Maybe Element)
getRoot :: forall (m :: * -> *).
MonadDOM m =>
IntersectionObserver -> m (Maybe Element)
getRoot IntersectionObserver
self = DOM (Maybe Element) -> m (Maybe Element)
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((IntersectionObserver
self IntersectionObserver
-> Getting (JSM JSVal) IntersectionObserver (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter IntersectionObserver (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"root") JSM JSVal -> (JSVal -> DOM (Maybe Element)) -> DOM (Maybe Element)
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM (Maybe Element)
forall a. FromJSVal a => JSVal -> JSM (Maybe a)
fromJSVal)
getRootUnsafe ::
(MonadDOM m, HasCallStack) => IntersectionObserver -> m Element
getRootUnsafe :: forall (m :: * -> *).
(MonadDOM m, HasCallStack) =>
IntersectionObserver -> m Element
getRootUnsafe IntersectionObserver
self
= DOM Element -> m Element
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
(((IntersectionObserver
self IntersectionObserver
-> Getting (JSM JSVal) IntersectionObserver (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter IntersectionObserver (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"root") JSM JSVal -> (JSVal -> DOM (Maybe Element)) -> DOM (Maybe Element)
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM (Maybe Element)
forall a. FromJSVal a => JSVal -> JSM (Maybe a)
fromJSVal) DOM (Maybe Element)
-> (Maybe Element -> DOM Element) -> DOM Element
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
DOM Element
-> (Element -> DOM Element) -> Maybe Element -> DOM Element
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> DOM Element
forall a. HasCallStack => String -> a
Prelude.error String
"Nothing to return") Element -> DOM Element
forall a. a -> JSM a
forall (m :: * -> *) a. Monad m => a -> m a
return)
getRootUnchecked ::
(MonadDOM m) => IntersectionObserver -> m Element
getRootUnchecked :: forall (m :: * -> *).
MonadDOM m =>
IntersectionObserver -> m Element
getRootUnchecked IntersectionObserver
self
= DOM Element -> m Element
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((IntersectionObserver
self IntersectionObserver
-> Getting (JSM JSVal) IntersectionObserver (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter IntersectionObserver (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"root") JSM JSVal -> (JSVal -> DOM Element) -> DOM Element
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM Element
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)
getRootMargin ::
(MonadDOM m, FromJSString result) =>
IntersectionObserver -> m result
getRootMargin :: forall (m :: * -> *) result.
(MonadDOM m, FromJSString result) =>
IntersectionObserver -> m result
getRootMargin IntersectionObserver
self
= DOM result -> m result
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((IntersectionObserver
self IntersectionObserver
-> Getting (JSM JSVal) IntersectionObserver (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter IntersectionObserver (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"rootMargin") JSM JSVal -> (JSVal -> DOM result) -> DOM result
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM result
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)
getThresholds :: (MonadDOM m) => IntersectionObserver -> m [Double]
getThresholds :: forall (m :: * -> *).
MonadDOM m =>
IntersectionObserver -> m [Double]
getThresholds IntersectionObserver
self
= DOM [Double] -> m [Double]
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM ((IntersectionObserver
self IntersectionObserver
-> Getting (JSM JSVal) IntersectionObserver (JSM JSVal)
-> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter IntersectionObserver (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"thresholds") JSM JSVal -> (JSVal -> DOM [Double]) -> DOM [Double]
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM [Double]
forall o. FromJSVal o => JSVal -> JSM [o]
fromJSArrayUnchecked)