##// END OF EJS Templates
Merge pull request #8281 from minrk/finish-8067...
Min RK -
r21194:74738e8d merge
parent child Browse files
Show More
@@ -368,6 +368,26 b' define(function(require){'
368 return env.notebook.scroll_manager.scroll(-1);
368 return env.notebook.scroll_manager.scroll(-1);
369 },
369 },
370 },
370 },
371 'scroll-cell-center': {
372 help: "Scroll the current cell to the center",
373 handler: function (env, event) {
374 if(event){
375 event.preventDefault();
376 }
377 var cell = env.notebook.get_selected_index();
378 return env.notebook.scroll_cell_percent(cell, 50, 0);
379 }
380 },
381 'scroll-cell-top': {
382 help: "Scroll the current cell to the top",
383 handler: function (env, event) {
384 if(event){
385 event.preventDefault();
386 }
387 var cell = env.notebook.get_selected_index();
388 return env.notebook.scroll_cell_percent(cell, 0, 0);
389 }
390 },
371 'save-notebook':{
391 'save-notebook':{
372 help: "Save and Checkpoint",
392 help: "Save and Checkpoint",
373 help_index : 'fb',
393 help_index : 'fb',
@@ -79,7 +79,7 b' define(['
79 'up' : 'ipython.move-cursor-up-or-previous-cell',
79 'up' : 'ipython.move-cursor-up-or-previous-cell',
80 'down' : 'ipython.move-cursor-down-or-next-cell',
80 'down' : 'ipython.move-cursor-down-or-next-cell',
81 'ctrl-shift--' : 'ipython.split-cell-at-cursor',
81 'ctrl-shift--' : 'ipython.split-cell-at-cursor',
82 'ctrl-shift-subtract' : 'ipython.split-cell-at-cursor'
82 'ctrl-shift-subtract' : 'ipython.split-cell-at-cursor',
83 };
83 };
84 };
84 };
85
85
@@ -351,11 +351,30 b' define(function (require) {'
351 * @return {integer} Pixel offset from the top of the container
351 * @return {integer} Pixel offset from the top of the container
352 */
352 */
353 Notebook.prototype.scroll_to_cell = function (index, time) {
353 Notebook.prototype.scroll_to_cell = function (index, time) {
354 return this.scroll_cell_percent(index, 0, time);
355 };
356
357 /**
358 * Scroll the middle of the page to a given cell.
359 *
360 * @param {integer} index - An index of the cell to view
361 * @param {integer} percent - 0-100, the location on the screen to scroll.
362 * 0 is the top, 100 is the bottom.
363 * @param {integer} time - Animation time in milliseconds
364 * @return {integer} Pixel offset from the top of the container
365 */
366 Notebook.prototype.scroll_cell_percent = function (index, percent, time) {
354 var cells = this.get_cells();
367 var cells = this.get_cells();
355 time = time || 0;
368 time = time || 0;
369 percent = percent || 0;
356 index = Math.min(cells.length-1,index);
370 index = Math.min(cells.length-1,index);
357 index = Math.max(0 ,index);
371 index = Math.max(0 ,index);
358 var scroll_value = cells[index].element.position().top-cells[0].element.position().top ;
372 var sme = this.scroll_manager.element;
373 var h = sme.height();
374 var st = sme.scrollTop();
375 var t = sme.offset().top;
376 var ct = cells[index].element.offset().top;
377 var scroll_value = st + ct - (t + .01 * percent * h);
359 this.scroll_manager.element.animate({scrollTop:scroll_value}, time);
378 this.scroll_manager.element.animate({scrollTop:scroll_value}, time);
360 return scroll_value;
379 return scroll_value;
361 };
380 };
General Comments 0
You need to be logged in to leave comments. Login now