feat: Hide page head while scrolling down

- To create more reading area in the form
This commit is contained in:
Suraj Shetty 2022-03-22 09:16:39 +05:30
parent 47d9f0573d
commit 7a9536332e
2 changed files with 10 additions and 5 deletions

View file

@ -47,13 +47,17 @@ frappe.ui.Page = class Page {
}
setup_scroll_handler() {
window.addEventListener('scroll', () => {
if (document.documentElement.scrollTop) {
$('.page-head').toggleClass('drop-shadow', true);
let last_scroll = 0;
window.addEventListener('scroll', frappe.utils.throttle(() => {
$('.page-head').toggleClass('drop-shadow', !!document.documentElement.scrollTop);
let current_scroll = document.documentElement.scrollTop;
if (current_scroll > 0 && last_scroll <= current_scroll) {
$('.page-head').css("top", "-15px");
} else {
$('.page-head').removeClass('drop-shadow');
$('.page-head').css("top", "var(--navbar-height)");
}
});
last_scroll = current_scroll;
}), 500);
}
get_empty_state(title, message, primary_action) {

View file

@ -88,6 +88,7 @@
top: var(--navbar-height);
background: var(--bg-color);
margin-bottom: 5px;
transition: 0.5s top;
.page-head-content {
height: var(--page-head-height);
}