var OriginTitle = document.title; var titleTime; document.addEventListener('visibilitychange', function () { if (document.hidden) { $('[rel="icon"]').attr('href', "/img/trhx2.png"); document.title = 'ヽ(●-`Д´-)ノ我等你很久了哦!😜'; clearTimeout(titleTime); } else { $('[rel="icon"]').attr('href', "/img/trhx2.png"); document.title = 'ヾ(Ő∀Ő3)ノ你终于回来了,我的宝贝💖!' + OriginTitle; titleTime = setTimeout(function () { document.title = OriginTitle; }, 2000); } }); (function($){ $.fn.snow = function(options){ var $flake = $('
').css({ 'position': 'absolute', 'z-index': '9999', 'top': '-50px', 'color': options.flakeColor || "#FFFFFF", 'font-size': options.minSize, 'opacity': 0.5 + Math.random(), 'pointer-events': 'none' // 防止雪花被点击 }).html('❄'); // 雪花符号 var documentHeight = $(document).height(), documentWidth = $(document).width(); var defaults = { minSize: 6, maxSize: 15, newOn: 1000, // 雪花生成频率 flakeColor: "#FFFFFF" // 雪花颜色 }; options = $.extend({}, defaults, options); // 确保页面不滚动 //$('html, body').css({'height': '100%', 'overflow': 'hidden'}); // 雪花动画 var interval = setInterval(function() { var startPositionLeft = Math.random() * documentWidth - 100, sizeFlake = options.minSize + Math.random() * options.maxSize, endPositionTop = documentHeight - 200, endPositionLeft = startPositionLeft - 500 + Math.random() * 500, durationFall = documentHeight * 10 + Math.random() * 5000; $flake.clone().appendTo('body').css({ left: startPositionLeft, opacity: 0.5 + Math.random(), // 雪花透明度 'font-size': sizeFlake }).animate({ top: endPositionTop, left: endPositionLeft, opacity: 0.2 }, durationFall, 'linear', function() { $(this).remove(); // 雪花掉落后移除 }); }, options.newOn); }; })(jQuery); // 初始化雪花飘落 $(function() { $.fn.snow({ minSize: 5, maxSize: 30, newOn: 500 }); // 监听滚动事件 var lastScrollTop = 0; var navbar = $('#nav'); // 导航栏 $(window).scroll(function(){ var currentScroll = $(this).scrollTop(); if (currentScroll > lastScrollTop) { // 向下滚动时,隐藏导航栏 navbar.stop().animate({'top': '-60px'}, 200); } else { // 向上滚动时,显示导航栏 navbar.stop().animate({'top': '0'}, 200); } lastScrollTop = currentScroll; // 更新滚动位置 }); });