1

Problem

By default, as I’m sure most of you are aware of, the step size for the TextArea isn’t too great. Is there a way in which you can change it into something greater—make it scroll faster, jump bigger steps per scroll?

What I’ve tried so far

API

I’ve looked through the API for the TextArea, but can’t seem to find something that would allow me to manipulate the speed of the TextArea’s scroll bar.

Stackoverflow

Reading up Stackoverflow, I found this, but using the code from that article’s top answer—I couldn’t get it to work even in the way that they suggested it would.

Moreover

It appears to me there’s no way of manipulating the speed of the ScrollBar attached to the TextArea, but I could truly be wrong.

Perhaps someone could point me in the right direction should there be a way in which you can speed the scroll bar up a little.

Community
  • 1
  • 1
D. Ataro
  • 1,711
  • 17
  • 38

1 Answers1

-1

This worked for my application despite the janky-ness of it. I'm sure it can be improved upon. Also a good technique for disabling scrolling altogether with javascript.

This function slows down the scroll speed / step size by manually setting the scroll top value based on a variable I have saved on the DOM element itself and I update the variable a set amount each call and then force the element to be scrolled there, overriding the browsers default scroll amount.

function elementScrolled(e) {
  // Ensure we have set a default scroll position for the element
  e.target.scrollPos = e.target.scrollPos || 0;

  // Determine if the user is scrolling up or down
  if (e.target.scrollTop > e.target.scrollPos) {
    // On each call of the function, only increment the scroll value by 1.
    e.target.scrollPos += 1
    e.target.scrollTop = e.target.scrollPos
  } 
  else if (e.target.scrollTop < e.target.scrollPos) {
    // On each call of the function, only decrement the scroll value by 1.
    e.target.scrollPos -= 1
    e.target.scrollTop = e.target.scrollPos
  }
}