reset album page bottom padding if scrollTop == 0

This commit is contained in:
geoffrey45
2022-07-02 12:36:00 +03:00
committed by Mungai Geoffrey
parent 14182e78cd
commit d830412035
2 changed files with 35 additions and 12 deletions
@@ -49,7 +49,7 @@ const scrollRight = () => {
<style lang="scss"> <style lang="scss">
.f-artists { .f-artists {
width: calc(100%); width: 100%;
padding: 0 $small; padding: 0 $small;
border-radius: $small; border-radius: $small;
user-select: none; user-select: none;
+34 -11
View File
@@ -12,7 +12,7 @@
class="rounded" class="rounded"
ref="albumbottomcards" ref="albumbottomcards"
:class="{ :class="{
bottomexpanded: !bottomContainerState, bottomexpanded: bottomContainerRaised,
}" }"
> >
<div class="click-to-expand" @click="toggleBottom"> <div class="click-to-expand" @click="toggleBottom">
@@ -46,11 +46,13 @@ import { onMounted, ref } from "vue";
const album = useAStore(); const album = useAStore();
const albumbottomcards = ref<HTMLElement>(null); const albumbottomcards = ref<HTMLElement>(null);
const bottomContainerState = ref(true); const bottomContainerRaised = ref(false);
let elem: HTMLElement = null;
let classlist: DOMTokenList = null; let classlist: DOMTokenList = null;
onMounted(() => { onMounted(() => {
classlist = document.getElementById("albumcontent").classList; elem = document.getElementById("albumcontent");
classlist = elem.classList;
}); });
onBeforeRouteUpdate(async (to) => { onBeforeRouteUpdate(async (to) => {
@@ -62,8 +64,16 @@ onBeforeRouteUpdate(async (to) => {
* Toggles the state of the bottom container. Adds the `addbottompadding` class that adds a bottom padding to the album content div. * Toggles the state of the bottom container. Adds the `addbottompadding` class that adds a bottom padding to the album content div.
*/ */
function toggleBottom() { function toggleBottom() {
bottomContainerState.value = !bottomContainerState.value; bottomContainerRaised.value = !bottomContainerRaised.value;
classlist.add("addbottompadding");
if (bottomContainerRaised.value) {
classlist.add("addbottompadding");
return;
}
if (elem.scrollTop == 0) {
classlist.remove("addbottompadding");
}
} }
/** /**
@@ -71,22 +81,26 @@ function toggleBottom() {
* Removes the bottom padding which was added when you expand the bottom container. * Removes the bottom padding which was added when you expand the bottom container.
*/ */
function resetBottomPadding() { function resetBottomPadding() {
if (bottomContainerRaised.value) return;
classlist.remove("addbottompadding"); classlist.remove("addbottompadding");
} }
</script> </script>
<style lang="scss"> <style lang="scss">
.al-view { .al-view {
scrollbar-width: none;
height: 100%; height: 100%;
position: relative; position: relative;
margin-right: -$small;
overflow: hidden; overflow: hidden;
.al-content { .al-content {
height: 100%; height: 100%;
overflow: auto; overflow: auto;
padding-bottom: 17rem; padding-bottom: 17rem;
padding-right: $small;
transition: all 0.5s; transition: all 0.5s;
z-index: -1 !important;
} }
.addbottompadding { .addbottompadding {
@@ -107,10 +121,9 @@ function resetBottomPadding() {
} }
#bottom-items { #bottom-items {
z-index: 77;
position: absolute; position: absolute;
bottom: 0; bottom: 0;
width: 100%; width: calc(100% - $small);
height: 15rem; height: 15rem;
background-color: $gray; background-color: $gray;
transition: all 0.5s ease; transition: all 0.5s ease;
@@ -118,15 +131,20 @@ function resetBottomPadding() {
display: grid; display: grid;
grid-template-rows: 2rem 1fr; grid-template-rows: 2rem 1fr;
.bottom-content {
overflow: hidden;
scroll-behavior: contain;
}
.click-to-expand { .click-to-expand {
height: 1.5rem; height: 1.5rem;
display: flex; display: flex;
align-items: center; align-items: center;
color: $gray1;
div { div {
margin: 0 auto; margin: 0 auto;
font-size: small; font-size: small;
color: $gray1;
cursor: default; cursor: default;
user-select: none; user-select: none;
display: flex; display: flex;
@@ -137,18 +155,23 @@ function resetBottomPadding() {
max-width: min-content; max-width: min-content;
transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out;
} }
&:hover {
color: $accent !important;
}
} }
} }
.bottomexpanded { .bottomexpanded {
height: 35rem !important; height: 32rem !important;
scroll-behavior: contain;
.arrow { .arrow {
transform: rotate(180deg) !important; transform: rotate(180deg) !important;
} }
.bottom-content { .bottom-content {
overflow: auto; overflow: auto !important;
scrollbar-width: none; scrollbar-width: none;
&::-webkit-scrollbar { &::-webkit-scrollbar {