mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 03:32:51 +02:00
style: optimize scrollbar styling, remove the auto-hide feature to fix page flickering issue
This commit is contained in:
parent
bd24e340e7
commit
d0e699d8cb
5 changed files with 10 additions and 54 deletions
|
@ -1,34 +0,0 @@
|
||||||
<script>
|
|
||||||
let scrollHandler: EventListener | undefined
|
|
||||||
|
|
||||||
function debounce(fn: () => void, delay: number) {
|
|
||||||
let timer: ReturnType<typeof setTimeout> | undefined
|
|
||||||
return function () {
|
|
||||||
clearTimeout(timer)
|
|
||||||
timer = setTimeout(fn, delay)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function initScrollbar() {
|
|
||||||
const html = document.documentElement
|
|
||||||
html.classList.remove('scrolling')
|
|
||||||
|
|
||||||
if (scrollHandler) {
|
|
||||||
window.removeEventListener('scroll', scrollHandler)
|
|
||||||
}
|
|
||||||
|
|
||||||
const hideScrollbar = debounce(() => {
|
|
||||||
html.classList.remove('scrolling')
|
|
||||||
}, 1500)
|
|
||||||
|
|
||||||
scrollHandler = () => {
|
|
||||||
html.classList.add('scrolling')
|
|
||||||
hideScrollbar()
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('scroll', scrollHandler, { passive: true })
|
|
||||||
}
|
|
||||||
|
|
||||||
initScrollbar()
|
|
||||||
document.addEventListener('astro:page-load', initScrollbar)
|
|
||||||
</script>
|
|
|
@ -19,14 +19,14 @@ const filteredHeadings = headings.filter(heading =>
|
||||||
---
|
---
|
||||||
|
|
||||||
{filteredHeadings.length > 0 && (
|
{filteredHeadings.length > 0 && (
|
||||||
<div class="mb-4 uno-round-border bg-secondary/5 2xl:(fixed left-0 top-43.5 max-w-[min(calc(50vw-38rem),13rem)] border-none bg-transparent)">
|
<div class="mb-4 uno-round-border bg-secondary/5 2xl:(fixed left-0 top-43.5 max-w-[min(calc(50vw-38rem),13rem)] border-none bg-secondary/0)">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="toc-toggle"
|
id="toc-toggle"
|
||||||
class="accordion-toggle"
|
class="accordion-toggle"
|
||||||
hidden
|
hidden
|
||||||
/>
|
/>
|
||||||
<div class="relative h-12 w-full bg-transparent">
|
<div class="relative h-12 w-full">
|
||||||
<label
|
<label
|
||||||
for="toc-toggle"
|
for="toc-toggle"
|
||||||
class="absolute inset-0 flex cursor-pointer items-center 2xl:(static flex c-secondary/40 transition-colors ease-out hover:c-secondary/80)"
|
class="absolute inset-0 flex cursor-pointer items-center 2xl:(static flex c-secondary/40 transition-colors ease-out hover:c-secondary/80)"
|
||||||
|
|
|
@ -5,7 +5,6 @@ import Header from '@/components/Header.astro'
|
||||||
import Navbar from '@/components/Navbar.astro'
|
import Navbar from '@/components/Navbar.astro'
|
||||||
import GithubCard from '@/components/Widgets/GithubCard.astro'
|
import GithubCard from '@/components/Widgets/GithubCard.astro'
|
||||||
import PhotoSwipe from '@/components/Widgets/PhotoSwipe.astro'
|
import PhotoSwipe from '@/components/Widgets/PhotoSwipe.astro'
|
||||||
import Scrollbar from '@/components/Widgets/Scrollbar.astro'
|
|
||||||
import themeConfig from '@/config'
|
import themeConfig from '@/config'
|
||||||
import Head from '@/layouts/Head.astro'
|
import Head from '@/layouts/Head.astro'
|
||||||
import { getPageInfo } from '@/utils/page'
|
import { getPageInfo } from '@/utils/page'
|
||||||
|
@ -48,7 +47,6 @@ const MarginBottom = isPost && themeConfig.comment?.enabled
|
||||||
<Footer />
|
<Footer />
|
||||||
</div>
|
</div>
|
||||||
<Button supportedLangs={supportedLangs} />
|
<Button supportedLangs={supportedLangs} />
|
||||||
<Scrollbar />
|
|
||||||
<GithubCard />
|
<GithubCard />
|
||||||
<PhotoSwipe />
|
<PhotoSwipe />
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -6,12 +6,8 @@
|
||||||
html {
|
html {
|
||||||
--at-apply: 'bg-background c-secondary antialiased';
|
--at-apply: 'bg-background c-secondary antialiased';
|
||||||
scrollbar-width: thin;
|
scrollbar-width: thin;
|
||||||
scrollbar-color: oklch(var(--un-preset-theme-colors-secondary) / 0) transparent;
|
|
||||||
scrollbar-gutter: stable both-edges;
|
|
||||||
transition: scrollbar-color 0.3s ease-out;
|
|
||||||
}
|
|
||||||
html.scrolling {
|
|
||||||
scrollbar-color: oklch(var(--un-preset-theme-colors-secondary) / 0.25) transparent;
|
scrollbar-color: oklch(var(--un-preset-theme-colors-secondary) / 0.25) transparent;
|
||||||
|
scrollbar-gutter: stable both-edges;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fix Flash Issue On iOS */
|
/* Fix Flash Issue On iOS */
|
||||||
|
@ -23,7 +19,7 @@ body::selection {
|
||||||
--at-apply: 'bg-mark';
|
--at-apply: 'bg-mark';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Heading Anchor Link >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
|
/* Heading Anchor Link */
|
||||||
.heading-anchor-link {
|
.heading-anchor-link {
|
||||||
--at-apply: 'inline-block translate-y-0.08em c-transparent';
|
--at-apply: 'inline-block translate-y-0.08em c-transparent';
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,13 @@
|
||||||
.heti :where(h4),
|
.heti :where(h4),
|
||||||
.heti :where(h5),
|
.heti :where(h5),
|
||||||
.heti :where(h6) {
|
.heti :where(h6) {
|
||||||
--at-apply: 'mb-4 mt-6 font-semibold text-primary';
|
--at-apply: 'mb-4 mt-6 font-semibold';
|
||||||
}
|
}
|
||||||
.heti :where(h1) {
|
.heti :where(h1) {
|
||||||
--at-apply: 'mt-9.6 text-7';
|
--at-apply: 'mt-9.6 text-7 text-primary';
|
||||||
}
|
}
|
||||||
.heti :where(h2) {
|
.heti :where(h2) {
|
||||||
--at-apply: 'mt-9.6 text-6';
|
--at-apply: 'mt-9.6 text-6 text-primary';
|
||||||
}
|
}
|
||||||
.heti :where(h3) {
|
.heti :where(h3) {
|
||||||
--at-apply: 'mt-6.5 text-5';
|
--at-apply: 'mt-6.5 text-5';
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
--at-apply: 'text-4';
|
--at-apply: 'text-4';
|
||||||
}
|
}
|
||||||
.heti :where(h6) {
|
.heti :where(h6) {
|
||||||
--at-apply: 'text-secondary';
|
--at-apply: 'font-normal';
|
||||||
}
|
}
|
||||||
.heti :where(h1),
|
.heti :where(h1),
|
||||||
.heti :where(h2),
|
.heti :where(h2),
|
||||||
|
@ -70,8 +70,8 @@
|
||||||
|
|
||||||
/* Links */
|
/* Links */
|
||||||
.heti :where(a:not(.gc-container)) {
|
.heti :where(a:not(.gc-container)) {
|
||||||
--at-apply: 'break-all font-medium tracking-0 underline underline-0.075em decoration-secondary/40 underline-offset-0.1em';
|
--at-apply: 'break-all font-semibold tracking-0 underline underline-0.075em decoration-secondary/80 underline-offset-0.15em';
|
||||||
--at-apply: 'transition-colors hover:(c-primary decoration-secondary/80) lg:underline-0.1em';
|
--at-apply: 'transition-colors hover:(c-primary decoration-primary/80) lg:underline-0.1em';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Images */
|
/* Images */
|
||||||
|
@ -94,10 +94,6 @@
|
||||||
.heti :where(pre) {
|
.heti :where(pre) {
|
||||||
--at-apply: 'mb-4 overflow-auto uno-round-border px-4 py-3 bg-secondary/5!';
|
--at-apply: 'mb-4 overflow-auto uno-round-border px-4 py-3 bg-secondary/5!';
|
||||||
scrollbar-width: thin;
|
scrollbar-width: thin;
|
||||||
scrollbar-color: oklch(var(--un-preset-theme-colors-secondary) / 0) transparent;
|
|
||||||
transition: scrollbar-color 0.3s ease-out;
|
|
||||||
}
|
|
||||||
.heti :where(pre:hover) {
|
|
||||||
scrollbar-color: oklch(var(--un-preset-theme-colors-secondary) / 0.15) transparent;
|
scrollbar-color: oklch(var(--un-preset-theme-colors-secondary) / 0.15) transparent;
|
||||||
}
|
}
|
||||||
.heti pre :where(code) {
|
.heti pre :where(code) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue