I have the following code that a gallery puts together:
<div class="contenedorGaleria">
<div class="m-p-g">
<div class="m-p-g__thumbs" data-google-image-layout data-max-height="350">
<?php
$pCarpeta="views/image/fotos/";
$mascaraTotal="*.jpg,*.JPG,*.png,*.PNG, *.JPEG, *.jpeg";
$total=count(glob($pCarpeta . "/{" . $mascaraTotal . "}",GLOB_BRACE));
$contador = 1;
while ( $contador<= $total) {
echo "<img src='views/image/fotos/thumbnail/".$contador.".jpg' data-full='views/image/fotos/".$contador.".jpg' class='m-p-g__thumbs-img'/>";
$contador++;
}
?>
</div>
<div class="m-p-g__fullscreen"></div>
</div>
I want the images to load in the DOM only if a total of pixels of the same is visible to the user so that the page does not get slow if the images inside the folder are many, try to use lazyload but not I can make it work because it hits me with dependencies of other files that I can not change anymore.
How can I detect by image inside the while how much is visible on the screen knowing that the maximum height is always 350 px?