Jump to content
Search Community

samuelgoddard

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by samuelgoddard

  1. Hey both @OSUblake @JoeH, I really love the hook approach and am trying to run it in a project of my own (also coming from locomotive!), it's all working fine I'm just looking for a method to "refresh" the smoothscroll instance, for example, when I filter some projects, the page height might change, is there a function I can use to do this? I've tried the following with no luck:

     

    import useScrollSmoother from '@/components/smooth-scroller'
    
    export default function Example() {
      const { smoother } = useScrollSmoother();
    
      function scrollUpdate() {
        smoother.refresh();
      }
      
      return (
        <button onClick={scrollUpdate}>Update Height!</button>
      )
    }

    Any help appreciated, cheers!

    • Like 1
  2. Hey @Blake! How would I use this in a React context?

     

    Small example of what I'm trying to achieve below:

    let smoother = null;
    
    useEffect(() => {
      smoother = ScrollSmoother.create({
        smooth: 1,
        normalizeScroll: true,
        effects: true
      })
    }, [smoother]);
    
    function filterScrollUpdate() {
      smoother.refresh()
    }

     

    Doing this I get `TypeError: smoother.refresh is not a function`

     

    Thank you!

     
    • Like 1
×
×
  • Create New...