mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-05-18 14:34:23 +02:00
Slide in + no ugly onload animation on mobile
This commit is contained in:
parent
90e984e98b
commit
c2e9477941
@ -88,7 +88,7 @@ export default ((userOpts?: Partial<Options>) => {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
id="mobile-explorer"
|
id="mobile-explorer"
|
||||||
class="collapsed"
|
class="collapsed hide-until-loaded"
|
||||||
data-behavior={opts.folderClickBehavior}
|
data-behavior={opts.folderClickBehavior}
|
||||||
data-collapsed={opts.folderDefaultState}
|
data-collapsed={opts.folderDefaultState}
|
||||||
data-savestate={opts.useSavedState}
|
data-savestate={opts.useSavedState}
|
||||||
|
@ -40,18 +40,7 @@ function toggleExplorer(this: HTMLElement) {
|
|||||||
if (document.querySelector("#mobile-explorer")) {
|
if (document.querySelector("#mobile-explorer")) {
|
||||||
// Disable scrolling one the page when the explorer is opened on mobile
|
// Disable scrolling one the page when the explorer is opened on mobile
|
||||||
const bodySelector = document.querySelector("#quartz-body")
|
const bodySelector = document.querySelector("#quartz-body")
|
||||||
if (bodySelector) {
|
if (bodySelector) bodySelector.classList.toggle("lock-scroll")
|
||||||
if (!bodySelector.classList.contains("lock-scroll")) {
|
|
||||||
bodySelector.setAttribute("scroll-position", `${window.scrollY}`)
|
|
||||||
bodySelector.classList.toggle("lock-scroll")
|
|
||||||
} else {
|
|
||||||
bodySelector.classList.toggle("lock-scroll")
|
|
||||||
window.scrollTo({
|
|
||||||
top: Number(bodySelector.getAttribute("scroll-position")),
|
|
||||||
behavior: "instant",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,6 +184,10 @@ document.addEventListener("nav", () => {
|
|||||||
observer.observe(lastItem)
|
observer.observe(lastItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hide explorer on mobile until it is requested
|
||||||
|
const hiddenUntilDoneLoading = document.querySelector("#mobile-explorer")
|
||||||
|
hiddenUntilDoneLoading?.classList.remove("hide-until-loaded")
|
||||||
|
|
||||||
toggleExplorerFolders()
|
toggleExplorerFolders()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,11 +1,29 @@
|
|||||||
@use "../../styles/variables.scss" as *;
|
@use "../../styles/variables.scss" as *;
|
||||||
|
|
||||||
// Sticky top bar (stays in place when scrolling down on mobile.
|
|
||||||
@media all and ($mobile) {
|
@media all and ($mobile) {
|
||||||
.page > #quartz-body .sidebar.left:has(.explorer) {
|
.page > #quartz-body {
|
||||||
box-sizing: border-box;
|
// Move page on mobile
|
||||||
position: sticky;
|
& > :not(.sidebar.left:has(.explorer)) {
|
||||||
background-color: var(--light);
|
transform: translateX(0);
|
||||||
|
transition: transform 300ms ease-in-out;
|
||||||
|
}
|
||||||
|
&.lock-scroll > :not(.sidebar.left:has(.explorer)) {
|
||||||
|
transform: translateX(100dvw);
|
||||||
|
//width: 100%;
|
||||||
|
transition: transform 300ms ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sticky top bar (stays in place when scrolling down on mobile.
|
||||||
|
.sidebar.left:has(.explorer) {
|
||||||
|
box-sizing: border-box;
|
||||||
|
position: sticky;
|
||||||
|
background-color: var(--light);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide until done loading
|
||||||
|
.hide-until-loaded ~ #explorer-content {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,19 +247,20 @@ li:has(> .folder-outer:not(.open)) > .folder-container > svg {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: var(--light);
|
background-color: var(--light);
|
||||||
max-width: 100dvw;
|
max-width: 100dvw;
|
||||||
//left: -100dvw;
|
left: -100dvw;
|
||||||
transform: translateX(-100dvw);
|
//transform: translateX(0);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
transition: all 300ms ease-in-out;
|
transition: transform 300ms ease-in-out;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: 2rem 2rem 4rem;
|
padding: 2rem;
|
||||||
height: calc(100dvh - 4rem);
|
height: calc(100dvh - 4rem);
|
||||||
max-height: calc(100dvh - 4rem);
|
max-height: calc(100dvh - 4rem);
|
||||||
margin-top: 2rem;
|
margin-top: 2rem;
|
||||||
visibility: visible;
|
visibility: hidden;
|
||||||
|
|
||||||
&:not(.collapsed) {
|
&:not(.collapsed) {
|
||||||
transform: translateX(0);
|
transform: translateX(100dvw);
|
||||||
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.overflow {
|
ul.overflow {
|
||||||
@ -250,7 +269,7 @@ li:has(> .folder-outer:not(.open)) > .folder-container > svg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.collapsed {
|
&.collapsed {
|
||||||
transform: translateX(-100dvw);
|
transform: translateX(0);
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user