Smooth Scrolling Additional coding help

lol, I was just going to tell you that was the problem.

But took my time as I was setting up an example where you use the Hype on click to call the Javascript.

The main adjustments I made were to give the grey buttons a class name each that reflects the id of the scroll to >element.

The jump to top elements also then use the single class name ‘top’ that reflects the top section element to scroll back to.

The javascript just gets the class name and uses that in the jQuery’s target id.

 var target = element.classList[1];//--- assumes class name 0 will be HYPE_element
  
      if (target.length) {
        $('html,body').animate({
          scrollTop: $("#"+target).offset().top
          
          
        // this value sets the speed (1000 is 1 second)  
        }, 1000);
        return false;
      }

smoothscrollingEdge2HypeDRAFT2_MH1.hype 2.zip (28.4 KB)

2 Likes