Skip to content

Instantly share code, notes, and snippets.

View 8mist's full-sized avatar

Grégoire Ciles 8mist

View GitHub Profile
@8mist
8mist / smooth-scroll.js
Last active January 23, 2024 12:44
Natif smooth scroll
const lerp = (a, b, n) => (1 - n) * a + n * b;
class SmoothScroll {
constructor() {
this.DOM = {
main: document.querySelector('main'),
wrapper: document.querySelector('.site-container')
};
if (!this.DOM.main) throw new Error('Please provide a main element.');
import {
forwardRef,
useCallback,
type ComponentPropsWithoutRef,
type ElementRef,
type MouseEventHandler,
} from 'react';
const PropagationStopper = forwardRef<ElementRef<'div'>, ComponentPropsWithoutRef<'div'>>(
({ children, ...props }, forwardedRef) => {