-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (35 loc) · 1.15 KB
/
script.js
File metadata and controls
36 lines (35 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(() => {
// add click event listener to each simple calendar sidebar list item
document.querySelectorAll("ul.simcal-events li").forEach((li) => {
li.addEventListener("click", () => {
const details = li.querySelector(".details");
li.classList.toggle("active");
const options = {
duration: 300,
easing: "ease-in-out",
fill: "forwards",
};
const inStyle = { opacity: 0, maxHeight: 0, marginTop: 0 };
const outStyle = {
opacity: 1,
maxHeight: `${details.scrollHeight}px`,
marginTop: 8,
};
if (li.classList.contains("active")) {
details.animate([inStyle, outStyle], options).onfinish = () => {
details.style.maxHeight = "none";
};
} else {
details.animate([outStyle, inStyle], options).onfinish = () => {
details.style.maxHeight = 0;
};
}
});
});
// add click event listener to each simple calendar sidebar list item link to prevent event bubbling
document.querySelectorAll("ul.simcal-events a").forEach((a) => {
a.addEventListener("click", (e) => {
e.stopPropagation();
});
});
})();