Created
February 14, 2023 21:50
-
-
Save joelrose/3cff912fa66bc4cc67370c772fd06e38 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function sleep(ms) { | |
| return new Promise(resolve => setTimeout(resolve, ms)); | |
| } | |
| function alignCalendarGraphLeft() { | |
| calendarSVG = document.getElementsByClassName("js-calendar-graph-svg")[0] | |
| realWidth = document.getElementsByClassName("js-calendar-graph")[0].offsetWidth | |
| calendarSVG.setAttribute("width", realWidth) | |
| console.log("Aligned calendar graph to the left") | |
| } | |
| alignCalendarGraphLeft() | |
| window.addEventListener("resize", alignCalendarGraphLeft); | |
| // when a different year is selected, the calendar graph is reloaded | |
| var elements = document.getElementsByClassName("js-year-link"); | |
| for (var i = 0; i < elements.length; i++) { | |
| elements[i].addEventListener("click", async (event) => { | |
| await sleep(600); // this may not work when your internet is slow | |
| alignCalendarGraphLeft(); | |
| }, false); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment