the-glorious-startpage/js/animate-dashboard.js

46 lines
979 B
JavaScript
Raw Normal View History

2020-06-04 04:23:40 +02:00
var dashboard = document.getElementById("rightDashboard");
2020-06-04 04:29:12 +02:00
var dashboardOverlay = document.getElementById("dashboardOverlay");
2020-06-04 04:23:40 +02:00
let rightDashboardVisibility = false;
const showDashboard = () => {
dashboard.classList.add('showRightDashboard');
2020-06-04 04:29:12 +02:00
// Show overlay
dashboardOverlay.classList.add('showDashboardOverlay');
2020-06-04 04:23:40 +02:00
rightDashboardVisibility = !rightDashboardVisibility;
}
const hideDashboard = () => {
dashboard.classList.remove('showRightDashboard');
dashboard.scrollTop = 0;
2020-06-04 04:29:12 +02:00
// Hide overlay
dashboardOverlay.classList.remove('showDashboardOverlay');
2020-06-04 04:23:40 +02:00
rightDashboardVisibility = !rightDashboardVisibility;
}
const toggleDashboard = () => {
if (rightDashboardVisibility) {
2020-06-04 06:15:59 +02:00
// Hide dashboard
2020-06-04 04:23:40 +02:00
hideDashboard();
} else {
2020-06-04 06:15:59 +02:00
// Show dashboard
2020-06-04 04:23:40 +02:00
showDashboard();
}
2020-06-04 04:29:12 +02:00
console.log('toggle dashboard');
}
2020-06-04 04:23:40 +02:00
2020-06-04 04:29:12 +02:00
dashboardOverlay.addEventListener(
"mouseup",
() => {
if (rightDashboardVisibility) {
toggleDashboard();
}
}
);