-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adjust HTML Element Sizes Based on Window Size
- Loading branch information
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
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
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
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(); |