Skip to content

Commit

Permalink
Merge pull request #2400 from Carreau/scroll_to_cell
Browse files Browse the repository at this point in the history
Add scroll_to_cell(cell_number) to the notebook
  • Loading branch information
Carreau committed Sep 13, 2012
2 parents 09cc3b2 + 7030423 commit a52d09c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions IPython/frontend/html/notebook/static/js/notebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,16 @@ var IPython = (function (IPython) {
});
};

Notebook.prototype.scroll_to_cell = function (cell_number, time) {
var cells = this.get_cells();
var time = time || 0;
cell_number = Math.min(cells.length-1,cell_number);
cell_number = Math.max(0 ,cell_number);
scroll_value = cells[cell_number].element.position().top-cells[0].element.position().top ;
this.element.animate({scrollTop:scroll_value}, time);
return scroll_value;
};


Notebook.prototype.scroll_to_bottom = function () {
this.element.animate({scrollTop:this.element.get(0).scrollHeight}, 0);
Expand Down

0 comments on commit a52d09c

Please sign in to comment.