Skip to content

Commit

Permalink
Dynamically update viewport on load
Browse files Browse the repository at this point in the history
  • Loading branch information
p0wen committed Sep 29, 2020
1 parent 241c244 commit 09bf857
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 3 additions & 2 deletions assets/css/style.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/* Main Page */
.html {
height: 100%;
--vh: 614px;
--vh: 7.96px;
}

.appview {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: calc(100 * var(--vh));;
height: 100%;
height: calc(100 * var(--vh));
z-index: -1;
}
.app {
Expand Down
13 changes: 11 additions & 2 deletions assets/js/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ if ("serviceWorker" in navigator) {
});
}

/**
* Fix Viewport for mobile browser (https://dev.to/admitkard/mobile-issue-with-100vh-height-100-100vh-3-solutions-3nae)
*/

window.addEventListener('resize', () => {
document.querySelector(':root').style
.setProperty('--vh', window.innerHeight/100 + 'px');
resizeView()
})

function resizeView() {
document.querySelector(':root').style
.setProperty('--vh', window.innerHeight/100 + 'px');
}

//get today's date for all kinds of function
let currentHour = new Date().getHours();
let currDate = new Date();
Expand Down Expand Up @@ -137,6 +145,7 @@ outline.style.strokeDashoffset = outlineLength;
// Initiliazation of the App

function init() {
resizeView()
dateSetup();
timeSensitivBackground(currentHour);
timerSettings();
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ <h5 class="modal-title">Congratulations</h5>
</div>

<!-- Load Scripts-->

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/js/bootstrap.min.js"></script>
Expand Down

0 comments on commit 09bf857

Please sign in to comment.