Page through an SC.ListView with the spacebar

Would you like to page down through an SC.ListView with the spacebar? Try this:

MyApp.CustomScrollView = SC.ScrollView.extend({
  
  contentView: SC.ListView.design({
    // ...bindings, etc., go here...

    keyDown: function(evt) {
      if (SC.PRINTABLE_KEYS[evt.charCode] === ' ') {
        var scroll_view = this.getPath('parentView.parentView');
        scroll_view.scrollBy(0, scroll_view.get('frame').height - 50);
        return YES;
      } else {
        return NO;
      }
    }
  })
});

This will page down one screen (minus 50 pixels) each time you hit the spacebar.

Notes

  1. sproutcorehacks posted this