jeudi 6 avril 2017

How does this jquery loop works?

I would like to ask how exactly this loop works ?

I've read a docs about .data() method but i can't figure out what is she doing in this example.At the begging we set those 'size' and big parameters just like this ?

if ($(window).width() >= 1025) {  
  $(function(){
    $('.navbar').data('size', 'big');

    $(window).scroll(function(){
      if ($(document).scrollTop() > 0) {
        if ($('.navbar').data('size') == 'big') {
          $('.navbar').data('size', 'small');
          $('.navbar').stop().animate({
            height: '5vh'
          }, 600);
        }
      } else {
        if ($('.navbar').data('size') == 'small') {
          $('.navbar').data('size', 'big');
          $('.navbar').stop().animate({
            height: '15vh'
          }, 600);
        }  
      }
    });

Aucun commentaire:

Enregistrer un commentaire