1/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
5 *
6 * The origin of this IDL file is
7 * https://wicg.github.io/IntersectionObserver/
8 */
9
10[ProbablyShortLivingWrapper, Pref="dom.IntersectionObserver.enabled"]
11interface IntersectionObserverEntry {
12  [Constant]
13  readonly attribute DOMHighResTimeStamp time;
14  [Constant]
15  readonly attribute DOMRectReadOnly? rootBounds;
16  [Constant]
17  readonly attribute DOMRectReadOnly boundingClientRect;
18  [Constant]
19  readonly attribute DOMRectReadOnly intersectionRect;
20  [Constant]
21  readonly attribute boolean isIntersecting;
22  [Constant]
23  readonly attribute double intersectionRatio;
24  [Constant]
25  readonly attribute Element target;
26};
27
28[Constructor(IntersectionCallback intersectionCallback,
29             optional IntersectionObserverInit options),
30 Pref="dom.IntersectionObserver.enabled"]
31interface IntersectionObserver {
32  [Constant]
33  readonly attribute Element? root;
34  [Constant]
35  readonly attribute DOMString rootMargin;
36  [Constant,Cached]
37  readonly attribute sequence<double> thresholds;
38  void observe(Element target);
39  void unobserve(Element target);
40  void disconnect();
41  sequence<IntersectionObserverEntry> takeRecords();
42
43  [ChromeOnly]
44  readonly attribute IntersectionCallback intersectionCallback;
45};
46
47callback IntersectionCallback =
48  void (sequence<IntersectionObserverEntry> entries, IntersectionObserver observer);
49
50dictionary IntersectionObserverEntryInit {
51  required DOMHighResTimeStamp time;
52  required DOMRectInit rootBounds;
53  required DOMRectInit boundingClientRect;
54  required DOMRectInit intersectionRect;
55  required Element target;
56};
57
58dictionary IntersectionObserverInit {
59  Element?  root = null;
60  DOMString rootMargin = "0px";
61  (double or sequence<double>) threshold = 0;
62};
63