Skip to content

Commit 6b1f02c

Browse files
committed
feature: add scroll driven animations
Also removes scroll snap.
1 parent cb76595 commit 6b1f02c

4 files changed

Lines changed: 33 additions & 19 deletions

File tree

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
<header
2-
class='fixed z-10 w-full animate-pulse px-2.5 pt-2'
2+
class='animate-pulse'
33
aria-label='Cargando encabezado'
44
>
55
<span
6-
class='bg-muted mx-auto block h-12 w-full max-w-7xl rounded-xl px-4 [--navbar-height:3.5rem] md:h-(--navbar-height) 2xl:max-w-(--breakpoint-2xl)'
6+
class='fixed z-10 w-full [animation:remove-padding_linear_both] px-2.5 pt-2 [animation-range:0_32px] [animation-timeline:scroll()] xl:animate-none'
77
aria-hidden='true'
8-
></span>
8+
>
9+
<span
10+
class='bg-muted relative mx-auto block h-12 w-full max-w-7xl [animation:remove-border_linear_both] rounded-xl px-4 [--navbar-height:3.5rem] [animation-range:0_32px] [animation-timeline:scroll()] md:h-(--navbar-height) xl:animate-none 2xl:max-w-(--breakpoint-2xl)'
11+
>
12+
<span
13+
class='absolute inset-0 -z-10 mx-auto h-[calc(var(--navbar-height)+0.5rem)] w-full max-w-[calc(var(--container-7xl)+0.5rem)] [animation:fade-in_linear_both] rounded-xl bg-neutral-800 blur-xl [--navbar-height:3.5rem] [animation-range:0_32px] [animation-timeline:scroll()] md:h-[calc(var(--navbar-height)+1rem)] md:max-w-[calc(var(--container-7xl)+1rem)] 2xl:max-w-(--breakpoint-2xl)'
14+
></span>
15+
</span>
16+
</span>
917
</header>

src/components/header.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function Header({ avatar, currentPage, DesktopBrand, MobileBrand }: HeaderProps)
145145
return (
146146
<>
147147
<Navbar
148-
className='fixed z-10 *:transition-colors *:ease-in-out'
148+
className='fixed z-10 [animation:remove-padding_linear_both] [animation-range:0_32px] [animation-timeline:scroll()] *:transition-colors *:ease-in-out xl:animate-none'
149149
style={{
150150
paddingRight: Object.values(underlays).some((bool) => bool)
151151
? `calc(var(--spacing) * 2.5 + ${scrollbarWidth}px)`
@@ -155,7 +155,7 @@ function Header({ avatar, currentPage, DesktopBrand, MobileBrand }: HeaderProps)
155155
isOpen={underlays.sideNavbar}
156156
onOpenChange={(isOpen) => underlaysStore.setKey('sideNavbar', isOpen)}
157157
>
158-
<Navbar.Nav>
158+
<Navbar.Nav className='[animation:remove-border_linear_both] [animation-range:0_32px] [animation-timeline:scroll()] xl:animate-none'>
159159
<Navbar.Section className='h-full min-h-fit'>
160160
{/* Desktop and mobile */}
161161
<Navbar.Logo
@@ -274,7 +274,7 @@ function Header({ avatar, currentPage, DesktopBrand, MobileBrand }: HeaderProps)
274274
</Navbar.Nav>
275275

276276
{/* Only for mobile */}
277-
<Navbar.Compact>
277+
<Navbar.Compact className='[animation:remove-border_linear_both] [animation-range:0_32px] [animation-timeline:scroll()] xl:animate-none'>
278278
<Navbar.Logo
279279
className='p-0'
280280
{...navbarLogoProps}
@@ -293,7 +293,7 @@ function Header({ avatar, currentPage, DesktopBrand, MobileBrand }: HeaderProps)
293293
</Navbar.Compact>
294294

295295
{/* Backdrop */}
296-
<span className='absolute inset-0 -z-10 mx-auto h-[calc(var(--navbar-height)+0.5rem)] w-full max-w-[calc(var(--container-7xl)+0.5rem)] rounded-xl bg-neutral-800 blur-xl [--navbar-height:3.5rem] md:h-[calc(var(--navbar-height)+1rem)] md:max-w-[calc(var(--container-7xl)+1rem)] 2xl:max-w-(--breakpoint-2xl)' />
296+
<span className='absolute inset-0 -z-10 mx-auto h-[calc(var(--navbar-height)+0.5rem)] w-full max-w-[calc(var(--container-7xl)+0.5rem)] [animation:fade-in_linear_both] rounded-xl bg-neutral-800 blur-xl [--navbar-height:3.5rem] [animation-range:0_32px] [animation-timeline:scroll()] md:h-[calc(var(--navbar-height)+1rem)] md:max-w-[calc(var(--container-7xl)+1rem)] 2xl:max-w-(--breakpoint-2xl)' />
297297
</Navbar>
298298

299299
{/* Only for "md" breakpoint */}

src/layouts/index.astro

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,7 @@ const avatar: AvatarProps = {
2626
description={BRAND.description}
2727
keywords='películas, ver películas, películas online, películas en línea, películas completas, películas en streaming, series, ver series, series online, series en línea, series completas, series en streaming, lucas hoz, hoz lucas, lucashoz, hozlucas, hozlucas28'
2828
pageURL={pageURL}
29-
classes={{
30-
html: 'snap-y snap-mandatory',
31-
body: {
32-
main: {
33-
wrapper:
34-
'[:is(&_astro-island)]:*:snap-center [:not(&_astro-island)]:snap-center [:is(&_astro-island)]:*:scroll-my-12 [:not(&_astro-island)]:scroll-my-12',
35-
},
36-
},
37-
}}
29+
classes={{ html: 'scroll-smooth' }}
3830
>
3931
<Header
4032
{avatar}

src/styles/globals.css

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,32 @@
6262

6363
@keyframes fade-in {
6464
0% {
65-
opacity: 0;
65+
opacity: 0%;
6666
}
6767

6868
100% {
69-
opacity: 1;
69+
opacity: 100%;
7070
}
7171
}
7272

7373
@keyframes fade-out {
7474
100% {
7575
display: none;
76-
opacity: 0;
76+
opacity: 100%;
77+
}
78+
}
79+
80+
@keyframes remove-border {
81+
100% {
82+
border-radius: 0px;
83+
border-style: none;
84+
border-width: 0px;
85+
}
86+
}
87+
88+
@keyframes remove-padding {
89+
100% {
90+
padding: 0px;
7791
}
7892
}
7993
}

0 commit comments

Comments
 (0)