From 1109132f09d75da9a28b649c7677bb6ce07c40c0 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:45 -0500 Subject: initial commit --- files/fi/web/api/intersectionobserver/index.html | 87 ++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 files/fi/web/api/intersectionobserver/index.html (limited to 'files/fi/web/api/intersectionobserver') diff --git a/files/fi/web/api/intersectionobserver/index.html b/files/fi/web/api/intersectionobserver/index.html new file mode 100644 index 0000000000..e62bd8b216 --- /dev/null +++ b/files/fi/web/api/intersectionobserver/index.html @@ -0,0 +1,87 @@ +--- +title: IntersectionObserver +slug: Web/API/IntersectionObserver +translation_of: Web/API/IntersectionObserver +--- +
{{APIRef("Intersection Observer API")}}
+ +

Intersection Observer API:n  rajapinta IntersectionObserver tarjoaa asynkronisen keinon tarkkailla muutoksia kohde-elementin ja sen esi-isäelementin tai ylätason dokumentin {{Glossary('viewport')}}:n kanssa. Näihin korkeamman tason DOM -elementteihin viitataan nimellä "root".

+ +

Kun IntersectionObserver luodaan, se konfiguroidaan tarkkailemaan DOM-elementtien näkyvyyttä suhteessa root:tiin. Tätä konfiguraatiota ei voida muuttaa sen jälkeen, kun se on initialisoitu, eli käytännössä yhdellä instanssilla tarkkaillaan elementtien näkyvyyttä yhden root -tason elementin suhteen. Yhdellä IntersectionObserver:lla voidaan kuitenkin tarkkailla monen elementin näkyvyyttä tämän suhteen.

+ +

Constructor

+ +
+
{{domxref("IntersectionObserver.IntersectionObserver()")}}
+
Luo uuden IntersectionObserver -instanssin, joka suorittaa annetun "callback" -function kun se havaitsee, että kohde-elementin näkyvyys on ylittänyt annetun kynnyksen.
+
+ +

Properties

+ +
+
{{domxref("IntersectionObserver.root")}} {{readonlyinline}}
+
Tietty elementin esi-isä -elementti, jonka suhteen kohteen {{domxref("element")}} näkyvyyttä tarkkaillaan. Jos tätä ei erityiesti määritellä, käytetään koko dokumentin juuren viewport:ia.
+
{{domxref("IntersectionObserver.rootMargin")}} {{readonlyinline}}
+
An offset rectangle applied to the root's {{Glossary('bounding box')}} when calculating intersections, effectively shrinking or growing the root for calculation purposes. The value returned by this property may not be the same as the one specified when calling the constructor as it may be changed to match internal requirements. Each offset can be expressed in pixels (px) or as a percentage (%). The default is "0px 0px 0px 0px".
+
{{domxref("IntersectionObserver.thresholds")}} {{readonlyinline}}
+
A list of thresholds, sorted in increasing numeric order, where each threshold is a ratio of intersection area to bounding box area of an observed target. Notifications for a target are generated when any of the thresholds are crossed for that target. If no value was passed to the constructor, 0 is used.
+
+ +

Methods

+ +
+
{{domxref("IntersectionObserver.disconnect()")}}
+
Stops the IntersectionObserver object from observing any target.
+
{{domxref("IntersectionObserver.observe()")}}
+
Tells the IntersectionObserver a target element to observe.
+
{{domxref("IntersectionObserver.takeRecords()")}}
+
Returns an array of {{domxref("IntersectionObserverEntry")}} objects for all observed targets.
+
{{domxref("IntersectionObserver.unobserve()")}}
+
Tells the IntersectionObserver to stop observing a particular target element.
+
+ +

Examples

+ +
var intersectionObserver = new IntersectionObserver(function(entries) {
+  // If intersectionRatio is 0, the target is out of view
+  // and we do not need to do anything.
+  if (entries[0].intersectionRatio <= 0) return;
+
+  loadItems(10);
+  console.log('Loaded new items');
+});
+// start observing
+intersectionObserver.observe(document.querySelector('.scrollerFooter'));
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("IntersectionObserver", "#intersection-observer-interface", "IntersectionObserver")}}{{Spec2('IntersectionObserver')}}
+ +

Browser compatibility

+ + + +

{{Compat("api.IntersectionObserver")}}

+ +

See also

+ + -- cgit v1.2.3-54-g00ecf