Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mumuy committed May 30, 2024
1 parent 70c9643 commit 0703bc6
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions static/script/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
$('.mod-panel h1').headroom({
autoHide:false
});

// 标题字体调整
(function(){
let $h1 = document.querySelector('.mod-panel h1');
let lastScrollTop = 0;
let offsetTop = $h1.offsetTop;
let resetTitle = function(){
let scrollTop = document.documentElement.scrollTop;
if(scrollTop!=lastScrollTop){
let fontSize = 36 - 15*Math.min(scrollTop/offsetTop,1);
$h1.style.fontSize = fontSize+'px';
lastScrollTop = scrollTop;
}
if(!navigator.userAgent.includes('Mobi')){
$('.mod-panel h1').headroom({
autoHide:false
});

// 标题字体调整
(function(){
let $h1 = document.querySelector('.mod-panel h1');
let lastScrollTop = 0;
let offsetTop = $h1.offsetTop;
let resetTitle = function(){
let scrollTop = document.documentElement.scrollTop;
if(scrollTop!=lastScrollTop){
let fontSize = 36 - 15*Math.min(scrollTop/offsetTop,1);
$h1.style.fontSize = fontSize+'px';
lastScrollTop = scrollTop;
}
requestAnimationFrame(resetTitle);
};
requestAnimationFrame(resetTitle);
};
requestAnimationFrame(resetTitle);
})();
})();
}


// 头部滚动
(function(){
Expand Down

0 comments on commit 0703bc6

Please sign in to comment.