Jump to content
Search Community

leomaubert

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by leomaubert

  1. Hi @akapowl!

    Thank you for you help.

     

    I would like to know if it is possible to add multiple anchor links? I tried to find a solution by duplicate the const slider but it doesn't work.

    Here a sneak peek of my attempt.

     

      gsap.registerPlugin(ScrollTrigger);
      let bodyScrollBar = Scrollbar.init(document.querySelector("#my-scrollbar"), {
        damping: 0.1,
      });
    ScrollTrigger.scrollerProxy("#my-scrollbar", {
        scrollTop(value) {
          if (arguments.length) {
            bodyScrollBar.scrollTop = value;
          }
          return bodyScrollBar.scrollTop;
        },
      });
      bodyScrollBar.addListener(ScrollTrigger.update);
    
    
      const slider= document.querySelector('#anchor1');
    
        var scrollToHere = slider.offsetTop;
    
        $('.button1').on('click', function() {
            bodyScrollBar.scrollTo(0, scrollToHere, 1000);});
    
      const slider= document.querySelector('#anchor2');
    
        var scrollToHere = slider.offsetTop;
    
        $('.button2').on('click', function() {
                  bodyScrollBar.scrollTo(0, scrollToHere, 1000);});

    I am a complete beginner so maybe the answer is really obvious 🧐

     

    Cheers,

    Léo

×
×
  • Create New...