Skip to content

Instantly share code, notes, and snippets.

View MarcusBondezan's full-sized avatar

Marcus Bondezan MarcusBondezan

  • Remessa Online
  • São José do Rio Preto - SP
  • 17:37 (UTC -03:00)
View GitHub Profile
@joshuacerbito
joshuacerbito / useScroll.js
Last active January 8, 2024 13:44
Custom React hook for listening to scroll events
/**
* useScroll React custom hook
* Usage:
* const { scrollX, scrollY, scrollDirection } = useScroll();
*/
import { useState, useEffect } from "react";
export function useScroll() {
const [lastScrollTop, setLastScrollTop] = useState(0);