IntersectionObserver.webidl (2126B)
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://w3c.github.io/IntersectionObserver/ 8 */ 9 10 [ProbablyShortLivingWrapper, Exposed=Window] 11 interface 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 [Exposed=Window] 29 interface IntersectionObserver { 30 [Throws] 31 constructor(IntersectionCallback intersectionCallback, 32 optional IntersectionObserverInit options = {}); 33 34 [Constant] 35 readonly attribute Node? root; 36 [Constant] 37 readonly attribute UTF8String rootMargin; 38 [Constant,Cached, Pref="dom.intersection_observer.scroll_margin.enabled"] 39 readonly attribute UTF8String scrollMargin; 40 [Constant,Cached] 41 readonly attribute sequence<double> thresholds; 42 undefined observe(Element target); 43 undefined unobserve(Element target); 44 undefined disconnect(); 45 sequence<IntersectionObserverEntry> takeRecords(); 46 }; 47 48 callback IntersectionCallback = 49 undefined (sequence<IntersectionObserverEntry> entries, IntersectionObserver observer); 50 51 dictionary IntersectionObserverEntryInit { 52 required DOMHighResTimeStamp time; 53 required DOMRectInit rootBounds; 54 required DOMRectInit boundingClientRect; 55 required DOMRectInit intersectionRect; 56 required Element target; 57 }; 58 59 dictionary IntersectionObserverInit { 60 (Element or Document)? root = null; 61 UTF8String rootMargin = "0px"; 62 [Pref="dom.intersection_observer.scroll_margin.enabled"] UTF8String scrollMargin = "0px"; 63 (double or sequence<double>) threshold = 0; 64 };