Search code examples
javascriptgoogle-closure-library

Use arrows to scroll a div


I want to replicate the functionality of a scroll bar with arrows, so that you can use up and down arrows to scroll inside a div. However, I am looking for a solution WITHOUT jQuery or any other library. I already found jScrollPane for jQuery, but I am using the Google closure Library.

If someone could please explain the principle behind it, or better, provide a Google Closure Library solution I would be most grateful.


Solution

  • I don't know of a way to use functionality built into the Closure Library to do this automatically, but basically, you'd need to overlay the arrows on top of what you want to scroll, and when they are clicked, change element.scrollTop or element.scrollLeft. You could even use https://closure-library.googlecode.com/svn/docs/class_goog_fx_dom_Scroll.html if you wanted to animate the scroll.