Skip to content

Instantly share code, notes, and snippets.

@joelrose
Created February 14, 2023 21:50
Show Gist options
  • Select an option

  • Save joelrose/3cff912fa66bc4cc67370c772fd06e38 to your computer and use it in GitHub Desktop.

Select an option

Save joelrose/3cff912fa66bc4cc67370c772fd06e38 to your computer and use it in GitHub Desktop.
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