Skip to content

Instantly share code, notes, and snippets.

@snaka
Created February 26, 2009 04:04
Show Gist options
  • Save snaka/70647 to your computer and use it in GitHub Desktop.
Save snaka/70647 to your computer and use it in GitHub Desktop.
buffer.js
---
/**
* Scrolls the buffer vertically <b>pages</b> pages.
*
* @param {number} pages The number of pages to scroll.
*/
scrollPages: function (pages)
{
let win = findScrollableWindow();
checkScrollYBounds(win, pages);
win.scrollByPages(pages);
},
/**
* Scrolls the buffer vertically <b>count</b> * 'scroll' rows.
*
* @param {number} count The multiple of 'scroll' lines to scroll.
* @param {number} direction The direction to scroll, down if 1 and up if -1.
*/
scrollByScrollSize: function (count, direction) // XXX: boolean
{
if (count > 0)
options["scroll"] = count;
let win = findScrollableWindow();
checkScrollYBounds(win, direction);
if (options["scroll"] > 0)
this.scrollLines(options["scroll"] * direction);
else // scroll half a page down in pixels
win.scrollBy(0, win.innerHeight / 2 * direction);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment