From c0a7bb5aba676466943a3d645e42a12f10e04b99 Mon Sep 17 00:00:00 2001
From: Simon Pieters If img's lazy loading attribute is in the Lazy state, img does not intersect the
- viewport, and img is not about to intersect the viewport, then
- return true. This allows for fetching the image during scrolling, when it does not, but is
- about to intersect the viewport.
Return false.
Each img
element have a boolean flag ready to be lazy loaded, initially
+ false.
For img
elements that will
+ lazy load, this flag can be set to true in the update the rendering steps,
+ which causes the image to load by continuing the update the image data steps.
Each Document
has a list of list of lazy loading images that
+ need intersection observation, initially empty.
This list is added to in the update the image data steps, and checked + in the run the lazy load intersection steps, which is called from the update + the rendering steps.
+ +The run the lazy load intersection steps steps for a Document
are as
+ follows:
For each img in the Document
's
+ list of lazy loading images that need intersection observation:
If img intersects the + viewport, or img is about to intersect the viewport, then set + img's ready to be lazy loaded flag to true.
+ +This allows for fetching the image during scrolling, when it does not, but is + about to intersect the viewport.
+Otherwise, observe img for intersection.
Empty the list of lazy loading images + that need intersection observation.
When the user agent is to update the image data of an img
element,
optionally with the restart animations flag set,
it must run the following steps:
Add the img
element to its node document's list of
+ lazy loading images that need intersection observation, if it isn't already
+ present.
Continue running this algorithm in parallel.
Wait until the will lazy load image steps no longer return true, given the +
Wait until the img
's ready to be lazy loaded flag is
+ true, or until the will lazy load image steps no longer return true, given the
img
.
Remove the img
element from its node document's list of
+ lazy loading images that need intersection observation, if it is present.
Queue an element task on the DOM manipulation task source
given the img
element to continue running the rest of this algorithm.
Document
, passing in now
as the timestamp.
+ For each fully active Document
in docs, run
+ the lazy load intersection steps for that Document
, passing in
+ now as the timestamp.
For each fully active Document
in docs, run
the update intersection observations steps for that Document
, passing in
now as the timestamp.