/* * Copyright (c) 2021, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include namespace Web::IntersectionObserver { struct IntersectionObserverInit { Optional, JS::Handle>> root; DeprecatedString root_margin { "0px"sv }; Variant> threshold { 0 }; }; // https://w3c.github.io/IntersectionObserver/#intersection-observer-interface class IntersectionObserver : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(IntersectionObserver, Bindings::PlatformObject); public: static WebIDL::ExceptionOr> construct_impl(JS::Realm&, WebIDL::CallbackType* callback, IntersectionObserverInit const& options = {}); virtual ~IntersectionObserver() override; void observe(DOM::Element& target); void unobserve(DOM::Element& target); void disconnect(); private: explicit IntersectionObserver(JS::Realm&); virtual JS::ThrowCompletionOr initialize(JS::Realm&) override; }; }