This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scroll(val,min,max){ | |
//ドキュメントの高さを取得 | |
var ch = document.body.scrollHeight; | |
//値がmaxより大きい時、何もしない | |
if(val > max){ | |
return; | |
} | |
//値がminより小さいときは、minの値で固定する | |
if(val < min){ | |
val = min; | |
} | |
//スクロールする位置を決定する | |
var sx = ch * (1 - (val - min)/(max - min)); | |
//指定の位置にスクロールさせる | |
window.scrollTo(0,sx); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment