Home > Net >  Mouse wheel scroll function is slow on exact page
Mouse wheel scroll function is slow on exact page

Time:09-30

I am not sure if the stack is overflow but mouse wheel is scrolling slow in home page of a website I designed in Google chrome. Is there some html or css property controlling the scroll speed or this is a performance issue?

the site address is ragaimen.com and the problem occures in first page (other pages work fine).

CodePudding user response:

We are facing the same issue after updating to the latest Chrome (94.0.4606.61, but someone else reported this happened from version 91), if your have a marquee on your page, it's very likely to make your mouse wheel scrolling slowly, and we believe it's Chrome's bug.

for chrome using, you can try opening chrome://flags/#smooth-scrolling and disable 「Smooth Scrolling」function.

for javascript solution, you can try the following code but actually not very smooth scrolling, I hope someone can improve it:

function wheel(event) {
      var delta = 0;
      if (event.wheelDelta) {(delta = event.wheelDelta / 120);}
      else if (event.detail) {(delta = -event.detail / 3);}

      handle(delta);
      event.returnValue = false;
  }

  function handle(delta) {
      var time = 100;
      var distance = 140; //adjust this for your page

      $('html, body').stop().animate({
          scrollTop: $(window).scrollTop() - (distance * delta)
      }, time );
  }

if (window.addEventListener) {window.addEventListener('DOMMouseScroll', wheel,  {passive: false});}
if (document.addEventListener) {document.addEventListener('DOMMouseScroll', wheel,  {passive: false});}
if (window.addEventListener) {window.addEventListener('mousewheel', wheel,  {passive: false});}
if (document.addEventListener) {document.addEventListener('mousewheel', wheel,  {passive: false});}
  • Related