From fe1099b06a865cdd60ce1b5e09ff1dea26ed1489 Mon Sep 17 00:00:00 2001 From: Samson Akol Date: Tue, 21 Nov 2023 16:35:26 +0300 Subject: [PATCH 1/5] Hides app bars on scroll down and show on scroll up --- .../assets/src/views/CorePage/AppBarPage.vue | 91 +++++++++++++++---- 1 file changed, 74 insertions(+), 17 deletions(-) diff --git a/kolibri/core/assets/src/views/CorePage/AppBarPage.vue b/kolibri/core/assets/src/views/CorePage/AppBarPage.vue index 1cea45d6330..704fece352f 100644 --- a/kolibri/core/assets/src/views/CorePage/AppBarPage.vue +++ b/kolibri/core/assets/src/views/CorePage/AppBarPage.vue @@ -4,17 +4,20 @@ here or in router, but somewhere -->
- - - + + + + +
- + + + { this.appBarHeight = this.$refs.appBar.$el.scrollHeight || 0; }); + window.addEventListener('scroll', this.handleScroll); + }, + beforeUnmount() { + window.removeEventListener('scroll', this.handleScroll); }, methods: { findFirstEl() { @@ -157,6 +177,19 @@ this.$refs.sideNav.focusFirstEl(); }); }, + handleScroll() { + const scrollTop = window.scrollY; + //Is user scrolling up? + if (scrollTop > this.lastScrollTop) { + this.hideAppBars = false; + } else { + this.hideAppBars = true; + } + + setTimeout(() => { + this.lastScrollTop = scrollTop; + }, 100); + }, }, }; @@ -167,6 +200,30 @@ @import '~kolibri-design-system/lib/styles/definitions'; + .v-leave { + opacity: 1; + } + + .v-leave-active { + transition: opacity 0.5s; + } + + .v-leave-to { + opacity: 0; + } + + .v-enter { + opacity: 0; + } + + .v-enter-active { + transition: opacity 0.5s; + } + + .v-enter-to { + opacity: 1; + } + .app-bar { @extend %dropshadow-8dp; From 934d067968d080a37cc6657d12e090ca2246cb60 Mon Sep 17 00:00:00 2001 From: Samson Akol Date: Wed, 29 Nov 2023 18:45:09 +0300 Subject: [PATCH 2/5] adds throttling to the listener. Refactors code --- .../assets/src/views/CorePage/AppBarPage.vue | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/kolibri/core/assets/src/views/CorePage/AppBarPage.vue b/kolibri/core/assets/src/views/CorePage/AppBarPage.vue index 704fece352f..2c4c8efdb86 100644 --- a/kolibri/core/assets/src/views/CorePage/AppBarPage.vue +++ b/kolibri/core/assets/src/views/CorePage/AppBarPage.vue @@ -61,6 +61,7 @@