Difference between revisions of "Template:INSA-UPS France/script scroll"

Line 3: Line 3:
 
<script type="text/javascript">
 
<script type="text/javascript">
  
$("#HQ_page").attr('id','');
+
$(document).ready(function(){
 
+
$("#HQ_page").attr('id','');
/* Scroll */
+
if (window.innerWidth>600){
+
$(window).scroll(function(){
+
  if ($(this).scrollTop() > 500) {
+
      $('body').addClass('header-fixed');
+
      if ($(this).scrollTop() > 580){
+
        $('#vertical_nav').addClass('can_move');
+
      }
+
      else{
+
        $('#vertical_nav').removeClass('can_move');
+
      }
+
  } else {
+
      $('body').removeClass('header-fixed');
+
  }
+
});
+
 
}
 
}
 
 
/*****/
 
$('.icon').click(function(e){
 
  $('body').toggleClass('with--sidebar');
 
});
 
 
$('#site-cache').click(function(e){
 
  $('body').removeClass('with--sidebar');
 
});
 
 
/****/
 
var contentSections = $('.article_offset'),
 
navigationItems = $('#vertical_nav .aside_circle');
 
 
updateNavigation();
 
$(window).on('scroll', function(){
 
updateNavigation();
 
});
 
 
 
 
 
function isScrolledIntoView(elem)
 
function isScrolledIntoView(elem)
Line 52: Line 17:
 
         return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
 
         return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
 
     }
 
     }
 +
 +
    $(document).ready(function(){
 +
      //$(".backToTop").hide(0);
 +
      if (window.innerWidth>600){
 +
        $(window).scroll(function(){
 +
          /*$('body').addClass('header-fixed');*/
 +
          if ($(this).scrollTop() > 500) {
 +
              $('body').addClass('header-fixed');
 +
              //$(".backToTop").show(500);
 +
              if ($(this).scrollTop() > 580){
 +
                $('#vertical_nav').addClass('can_move');
 +
              }
 +
              else{
 +
                $('#vertical_nav').removeClass('can_move');
 +
              }
 +
          } else {
 +
              $('body').removeClass('header-fixed');
 +
              //$(".backToTop").hide(500);
 +
          }
 +
          /*if (isScrolledIntoView('footer')){
 +
            $(".backToTop").hide(500);
 +
          }*/
 +
        });
 +
      }
 +
    });
 +
 +
 +
    $(document).ready(function(){
 +
        $('.icon').click(function(e){
 +
          $('body').toggleClass('with--sidebar');
 +
        });
 +
       
 +
        $('#site-cache').click(function(e){
 +
          $('body').removeClass('with--sidebar');
 +
        });
 +
 +
    });
 +
 +
 +
  $(document).ready(function($){
 +
  var contentSections = $('.article_offset'),
 +
  navigationItems = $('#vertical_nav .aside_circle');
 +
 +
  updateNavigation();
 +
  $(window).on('scroll', function(){
 +
    updateNavigation();
 +
    });
 +
  
 
   function updateNavigation() {
 
   function updateNavigation() {
Line 72: Line 85:
 
         );
 
         );
 
   }
 
   }
 +
});
  
 
</script>
 
</script>

Revision as of 09:00, 2 June 2017