Skip to content

Commit

Permalink
feat: Adjust HTML Element Sizes Based on Window Size
Browse files Browse the repository at this point in the history
  • Loading branch information
skang132 committed May 29, 2024
1 parent 983748e commit 4fa2bea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.8.5/d3.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<script src="https://use.fontawesome.com/releases/v6.3.0/js/all.js" crossorigin="anonymous"></script>
Expand Down Expand Up @@ -161,5 +162,6 @@
<script src="static/js/article.js"></script>
<script src="static/js/clickbait.js"></script>
<script src="static/js/result.js"></script>
<script src="static/js/window.js"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions static/js/window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function scaleDashboard() {
const dashboard = document.querySelector('.dashboard');
const layoutSidenavContent = document.querySelector('#layoutSidenav_content');

const scaleX = layoutSidenavContent.offsetWidth / 1330;
const scaleY = layoutSidenavContent.offsetHeight / 1045;
const scale = Math.min(scaleX, scaleY);

if (layoutSidenavContent.offsetWidth < 1680) {
dashboard.style.transform = `scale(${scale})`;
}
else {
dashboard.style.transform = `scale(${scaleX*0.99}, ${scaleY})`;
}

dashboard.style.transformOrigin = '0 0px';
}

window.addEventListener('resize', scaleDashboard);
scaleDashboard();

0 comments on commit 4fa2bea

Please sign in to comment.