How to upload images after scroll when in view-port?

Asked

Viewed 708 times

0

Look at this page:

https://www.nubank.com.br/gerando-boletos/

It has the following structure:

<p>titulo do post</p>
<img src>

<p>titulo do post</p>
<img src>

<p>titulo do post</p>
<img src>

But what I’m wondering is how to make the effect of appearing gradually that occurs in the images ONLY when we scroll the page and then get into the image.

I must search for what?

According to a colleague’s reply below, I tried it the way below and it did not work.

The picture only appears. I confirmed the lnkagem of the files

<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />



<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="jquery.lazyload.js"></script>


<p>Titulo.</p>
<img class="lazy" src="payment_swipe.png">

<script>
  $(function() {

      $("img.lazy").lazyload({
         effect : "fadeIn"
      })


  });
</script>
  • The attribute src you replaced by data-original in the image.

  • <img class="Lazy" date-original="payment_swipe.png">, the image appeared normally but the effect did not occur

  • I think I got it, I took the latest versions of Jquery and Plugin and it worked. Only fadein is happening too fast. There’s a way to slow it down?

  • just add effectspeed: 900 in the method parameters...

  • And then it worked?

  • yes, it did. Thank you. I also found Scrollreveal which is also very good. Then look there. https://scrollrevealjs.org/

Show 1 more comment

1 answer

1


Either you use some Javascript developed to do this effect or you use some plugin ready, I suggest the Lazy Load:

<script src="jquery.js"></script> <!-- jQuery necessário -->
<script src="jquery.lazyload.js"></script>

<p>titulo do post</p>
<img class="lazy"  data-original="img/example.jpg">

<p>titulo do post</p>
<img class="lazy"  data-original="img/example.jpg">

<p>titulo do post</p>
<img class="lazy"  data-original="img/example.jpg">

<script>
    $(function(){
        $("img.lazy").lazyload();
    });
</script>

In general this is the most used, you can later customize the effects and everything, ai goes from your need and availability.

  • So I tried that way but it didn’t work. Could you put something online like that doing you a favor? I put it to the question how I tried. Maybe I did wrong!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.