Site Notice

hello, world

Difference between revisions of "MediaWiki:Js-blog.js"

From Project-EPB Commons
Line 10: Line 10:
 
});
 
});
 
/** 自动神隐顶部条 **/
 
/** 自动神隐顶部条 **/
var lastScrollY = 0;
+
$(function(){
window.onscroll = function() {
+
  var lastScrollY = 0;
 +
  $(window).scroll(function() {
 
     //变化量可自行修改,使其在指定高度内滚动时不隐藏
 
     //变化量可自行修改,使其在指定高度内滚动时不隐藏
     if (window.scrollY - lastScrollY > 0 && window.scrollY > 500)
+
     if (window.scrollY - lastScrollY > 0 && window.scrollY > 500) {
    {
+
      //往下滚动,隐藏导航栏
        //往下滚动,隐藏导航栏
+
      $('.sq-site-header').addClass('header-hide');
        $('.sq-site-header').addClass('header-hide');
+
      $('#toast-container').addClass('notify-hide');
        $('#toast-container').addClass('notify-hide');
+
    } else if (window.scrollY - lastScrollY < 0) {
 +
      //往上滚动,显示导航栏(Safari会有BUG,尴尬)
 +
      $('.sq-site-header').removeClass('header-hide');
 +
      $('#toast-container').removeClass('notify-hide');
 
     }
 
     }
    else if (window.scrollY - lastScrollY < 0)
+
      lastScrollY = window.scrollY;
     {
+
  });
        //往上滚动,显示导航栏(Safari会有BUG,尴尬)
+
 
        $('.sq-site-header').removeClass('header-hide');
+
  $('.sq-site-header').mouseover(function(){
        $('#toast-container').removeClass('notify-hide');
+
     $('.sq-site-header, #toast-container').addClass('header-is-hover');
    }
+
  }).mouseout(function(){
        lastScrollY = window.scrollY;
+
    $('.sq-site-header, #toast-container').removeClass('header-is-hover');
}
+
  });
 +
});

Revision as of 13:45, 6 September 2019

/**
 *『Wjghj Project Static』
 * This _JavaScript_ code is from https://common.wjghj.cn
 * CC BY-NC-SA
 * For Wjghj Wordpress https://blog.wjghj.cn
 **/
/** 复制时版权声明 **/
$(window).on('copy',function(){
  toastr['warning']($('#sq-middle-footer .license-description').html(),'您刚刚复制了'+$('.sq-site-title a').text()+'上的内容!');
});
/** 自动神隐顶部条 **/
$(function(){
  var lastScrollY = 0;
  $(window).scroll(function() {
    //变化量可自行修改,使其在指定高度内滚动时不隐藏
    if (window.scrollY - lastScrollY > 0 && window.scrollY > 500) {
      //往下滚动,隐藏导航栏
      $('.sq-site-header').addClass('header-hide');
      $('#toast-container').addClass('notify-hide');
    } else if (window.scrollY - lastScrollY < 0) {
      //往上滚动,显示导航栏(Safari会有BUG,尴尬)
      $('.sq-site-header').removeClass('header-hide');
      $('#toast-container').removeClass('notify-hide');
    }
      lastScrollY = window.scrollY;
  });

  $('.sq-site-header').mouseover(function(){
    $('.sq-site-header, #toast-container').addClass('header-is-hover');
  }).mouseout(function(){
    $('.sq-site-header, #toast-container').removeClass('header-is-hover');
  });
});