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

Line 1: Line 1:
 
<html>
 
<html>
<script>
+
 
$(document).ready(function(){
+
<script type="text/javascript">
alert("Hello");
+
 
 +
$(document).ready(function(){
 +
                alert("Hello");
 +
$("#HQ_page").attr('id','');
 
});
 
});
 +
 +
function isScrolledIntoView(elem)
 +
    {
 +
        var docViewTop = $(window).scrollTop();
 +
        var docViewBottom = docViewTop + $(window).height();
 +
 +
        var elemTop = $(elem).offset().top;
 +
        var elemBottom = elemTop + $(elem).height();
 +
 +
        return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
 +
    }
 +
 +
    $(document).ready(function(){
 +
      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');
 +
          }
 +
        });
 +
      }
 +
    });
 +
 +
 +
    $(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() {
 +
    contentSections.each(function(){
 +
      $this = $(this);
 +
 +
      var activeSection = $('#vertical_nav a[href="#'+$this.attr('id')+'"]').data('number') - 1;
 +
      if ( ( $this.offset().top - $(window).height()/2 < $(window).scrollTop() ) && ( $this.offset().top + $this.height() - $(window).height()/2 > $(window).scrollTop() ) ) {
 +
        navigationItems.eq(activeSection).addClass('is-selected');
 +
      }else {
 +
        navigationItems.eq(activeSection).removeClass('is-selected');
 +
      }
 +
    });
 +
  }
 +
 +
  function smoothScroll(target) {
 +
        $('body,html').animate(
 +
          {'scrollTop':target.offset().top},
 +
          600
 +
        );
 +
  }
 +
});
 +
 
</script>
 
</script>
 +
 +
 
</html>
 
</html>

Revision as of 12:26, 2 June 2017