Skip to content

Commit

Permalink
Claude sonnet understands CSS even more poorly than I do
Browse files Browse the repository at this point in the history
  • Loading branch information
DeboAtWinterlight committed Aug 25, 2024
1 parent b160373 commit e8612f5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
</head>

<body>
<div id="scrollable-area"></div>
<div id="scrollable-area">
<div id="center-point"></div>
</div>
</body>
</html>
24 changes: 9 additions & 15 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
const viewportDimensions = {
x: 50000,
y: 50000,
};

document.addEventListener("load", function () {
const scrollableArea = document.getElementById("scrollable-area");
const viewportWidth = window.innerWidth;
const viewportHeight = window.innerHeight;

// Calculate the center position
const scrollToX = (viewportDimensions.x - viewportWidth) / 2;
const scrollToY = (viewportDimensions.y - viewportHeight) / 2;

console.log(`Center is: ${scrollToX}, ${scrollToY}`);
// Set the initial scroll position
window.scrollTo(scrollToX, scrollToY);

// Prevent default touch behavior to allow custom scrolling
scrollableArea.addEventListener(
Expand All @@ -41,4 +26,13 @@ document.addEventListener("load", function () {
const walkY = (y - startY) * 2;
window.scrollTo(scrollLeft - walkX, scrollTop - walkY);
});

const centerPoint = document.getElementById("center-point");

// Scroll to the center point
centerPoint.scrollIntoView({
behavior: "auto",
block: "center",
inline: "center",
});
});
9 changes: 9 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ body {
#scrollable-area {
width: 50000px;
height: 50000px;
position: relative;
background-image: url("./img/forest-tile-512x512.jpg");
background-repeat: repeat;
}

#center-point {
position: absolute;
top: 50%;
left: 50%;
width: 1px;
height: 1px;
}

0 comments on commit e8612f5

Please # to comment.