Skip to content

Commit

Permalink
Fix Horizontal Default Scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
athuler committed Oct 28, 2023
1 parent d564378 commit d1eee95
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,21 @@ function connectAll() {

function Scrolldown() {
var rect = document.getElementById("title").getBoundingClientRect();
console.log((rect.right+rect.left)/2);
console.log(document.body.scrollWidth);
window.scroll(document.body.scrollWidth*0.25,0);

const maxWidth = document.body.scrollWidth - window.innerWidth;
console.log("% page " + (window.pageXOffset * 100) / maxWidth);

//console.log("Rect x: " + rect.x);
console.log("Rect Left: " + rect.left);
console.log("Rect Right: " + rect.right);
console.log("Scroll Width: " + document.body.scrollWidth);
console.log("Screen Width: " + screen.width);
var scrollHorizDist = window.scrollX + rect.left - (rect.left + rect.right)/2;
var scrollHorizDist = window.scrollX + rect.left - rect.left;
var scrollHorizDist = (document.body.scrollWidth - window.innerWidth) / 2;

console.log(scrollHorizDist);
window.scroll(scrollHorizDist,0);
}

window.onload = Scrolldown;
Expand Down

0 comments on commit d1eee95

Please sign in to comment.