shlogg · Early preview
Hayyan Hami @hayyaun

Triggering Animations Based On Scroll Direction And Section Navigation

Trigger animations based on scroll direction & section navigation with `useSection` hook. Manage global state with zustand, watch section changes & create custom hooks for seamless transitions.

Sometimes, you may want to trigger an animation for a specific section based on whether the user has switched to that section. Here’s how you can achieve this: 

  
  
  Usage

By using this hook, you can run animations based on scroll direction while maintaining consistency between transitions. In certain scenarios, you may want to trigger different animations depending on the section you’re navigating from or to or even the direction if going forward or backward. We'll be building this hook in this post.

// SecondSection.tsx
import { Section } from './enums.ts'
export default function Secon...