/* * Copyright (c) 2021, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Web::IntersectionObserver { struct IntersectionObserverInit { Optional, NonnullRefPtr>> root; String root_margin { "0px"sv }; Variant> threshold { 0 }; }; // https://w3c.github.io/IntersectionObserver/#intersection-observer-interface class IntersectionObserver : public RefCounted , public Bindings::Wrappable { public: using WrapperType = Bindings::IntersectionObserverWrapper; static NonnullRefPtr create_with_global_object(JS::GlobalObject&, Bindings::CallbackType const& callback, IntersectionObserverInit const& options = {}); void observe(DOM::Element& target); void unobserve(DOM::Element& target); void disconnect(); }; }