Difference between revisions of "Template:XJTU-China/home.js"

Line 4: Line 4:
 
   $(window).scroll(function() {
 
   $(window).scroll(function() {
 
     if ($(this).scrollTop() == 0) {
 
     if ($(this).scrollTop() == 0) {
       $('header li a, header .nav-head').animate({lineHeight: '84px'}, 400, 'linear');
+
       $('header li a').animate({lineHeight: '74px'}, 200, 'linear');
       $('header .nav-pic').animate({marginBottom: '15px'}, 400, 'linear');
+
       $('.nav-head-wrapper').animate({top: '10px'}, 200, 'linear');
       $('header').animate({opacity: '0.7'}, 400, 'linear');
+
       $('header').animate({opacity: '0.85'}, 200, 'linear');
 
       $('header').data('expend', 'true');
 
       $('header').data('expend', 'true');
 
       console.log('scoll to the top');
 
       console.log('scoll to the top');
     } else if ($(this).scrollTop() >= 100 && $('header').data('expend') != 'false') {
+
     } else if ($(this).scrollTop() >= 40 && $('header').data('expend') != 'false') {
       $('header li a, header .nav-head').animate({lineHeight: '54px'}, 200, 'linear');
+
       $('.nav-head-wrapper').animate({top: '0'}, 400, 'linear');
       $('header .nav-pic').animate({marginBottom: '0'}, 200, 'linear');
+
       $('header li a').animate({lineHeight: '54px'}, 200, 'linear');
 
       $('header').animate({opacity: '1'}, 200, 'linear');
 
       $('header').animate({opacity: '1'}, 200, 'linear');
 
       $('header').data('expend', 'false');
 
       $('header').data('expend', 'false');
Line 72: Line 72:
 
   $('.content-title').waypoint(function(){
 
   $('.content-title').waypoint(function(){
 
     title_show(this.element);
 
     title_show(this.element);
   }, {offset: 'bottom-in-view'});
+
   }, {offset: '100%'});
 +
  $('.content-title').waypoint(function(){
 +
    title_show(this.element);
 +
  }, {offset: '-40px'});
 
   $('.content-text:not(#content-block-2 .content-text)').waypoint(function(){
 
   $('.content-text:not(#content-block-2 .content-text)').waypoint(function(){
 
     text_show(this.element);
 
     text_show(this.element);
   }, {offset: 'bottom-in-view'});
+
   }, {offset: '100%'});
 +
  $('.content-text:not(#content-block-2 .content-text)').waypoint(function(){
 +
    text_show(this.element);
 +
  }, {offset: '-40px'});
 
   $('#content-block-2 .content-text').waypoint(function(){
 
   $('#content-block-2 .content-text').waypoint(function(){
 
     text_show_r(this.element);
 
     text_show_r(this.element);
 +
  }, {offset: '100%'});
 +
  $('#content-block-2 .content-text').waypoint(function(){
 +
    text_show_r(this.element);
 +
  }, {offset: '-40px'});
 +
 +
  // team picture
 +
  $("#content-block-4").waypoint(function() {
 +
    if ($("#content-block-4").data('inview') != 'true') {
 +
      $('.banner-pic-wrapper').hide();
 +
      $('#content-block-4-pic').show();
 +
      $("#content-block-4").data('inview', 'true');
 +
    } else {
 +
      $('.banner-pic-wrapper').show();
 +
      $('#content-block-4-pic').hide();
 +
      $("#content-block-4").data('inview', 'false');
 +
    }
 
   }, {offset: 'bottom-in-view'});
 
   }, {offset: 'bottom-in-view'});
 +
 
});
 
});

Revision as of 19:44, 7 October 2018

$(document).ready(function(){

 // header scroll to top animation
 $(window).scroll(function() {
   if ($(this).scrollTop() == 0) {
     $('header li a').animate({lineHeight: '74px'}, 200, 'linear');
     $('.nav-head-wrapper').animate({top: '10px'}, 200, 'linear');
     $('header').animate({opacity: '0.85'}, 200, 'linear');
     $('header').data('expend', 'true');
     console.log('scoll to the top');
   } else if ($(this).scrollTop() >= 40 && $('header').data('expend') != 'false') {
     $('.nav-head-wrapper').animate({top: '0'}, 400, 'linear');
     $('header li a').animate({lineHeight: '54px'}, 200, 'linear');
     $('header').animate({opacity: '1'}, 200, 'linear');
     $('header').data('expend', 'false');
   }
 });
 // banner text showing animation
 $('#text-d').fadeIn(800);
 $('#text-e').delay(800).fadeIn(800);
 $('#text-cose').delay(1600).fadeIn(1000);
 $('.banner-sub-text').delay(3000).fadeIn(1000);
 $('.banner-up-arrow').delay(4000).fadeIn(800);
 // banner scroll hint animation
 setInterval(function(){
   $('.banner-up-arrow').fadeTo(1400, 0.4).fadeTo(1400, 0.8);
 }, 2800);
 var iter=1;
 // banner picture cycling animation
 setInterval(function(){
   if (iter == $('.banner-pic-wrapper').children().length-1) {
     var next_iter = 1;
   } else {
     var next_iter = iter+1;
   }
   $('#banner-pic-'+next_iter).fadeIn(1000);
   $('#banner-pic-'+iter).delay(500).fadeOut(1000);
   iter = next_iter;
 }, 6000)
 // content text showing animation
 var title_show = function(element) {
   if ($(element).data('inview') == 'true') {
     $(element).animate({top: '-40px', opacity: '0'}, 300, 'swing');
     $(element).data('inview', 'false'); 
   } else {
     $(element).animate({top: '0', opacity: '1'}, 600, 'swing');
     $(element).data('inview', 'true');
   }
 };
 var text_show = function(element) {
   if ($(element).data('inview') == 'true') {
     $(element).animate({left: '-100px', opacity: '0'}, 400, 'swing');
     $(element).data('inview', 'false'); 
   } else {
     $(element).animate({left: '0', opacity: '1'}, 1000, 'swing');
     $(element).data('inview', 'true');
   }
 };
 var text_show_r = function(element) {
   if ($(element).data('inview') == 'true') {
     $(element).animate({left: '100px', opacity: '0'}, 400, 'swing');
     $(element).data('inview', 'false'); 
   } else {
     $(element).animate({left: '0', opacity: '1'}, 1000, 'swing');
     $(element).data('inview', 'true');
   }
 };
 $('.content-title').waypoint(function(){
   title_show(this.element);
 }, {offset: '100%'});
 $('.content-title').waypoint(function(){
   title_show(this.element);
 }, {offset: '-40px'});
 $('.content-text:not(#content-block-2 .content-text)').waypoint(function(){
   text_show(this.element);
 }, {offset: '100%'});
 $('.content-text:not(#content-block-2 .content-text)').waypoint(function(){
   text_show(this.element);
 }, {offset: '-40px'});
 $('#content-block-2 .content-text').waypoint(function(){
   text_show_r(this.element);
 }, {offset: '100%'});
 $('#content-block-2 .content-text').waypoint(function(){
   text_show_r(this.element);
 }, {offset: '-40px'});
 // team picture
 $("#content-block-4").waypoint(function() {
   if ($("#content-block-4").data('inview') != 'true') {
     $('.banner-pic-wrapper').hide();
     $('#content-block-4-pic').show();
     $("#content-block-4").data('inview', 'true');
   } else {
     $('.banner-pic-wrapper').show();
     $('#content-block-4-pic').hide();
     $("#content-block-4").data('inview', 'false');
   }
 }, {offset: 'bottom-in-view'});

});