mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
Add scroll_to_cell(cell_number) to the notebook
This commit is contained in:
parent
e08873d7f6
commit
e0e519afcb
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user