Show More
@@ -368,24 +368,24 define(function(require){ | |||||
368 | return env.notebook.scroll_manager.scroll(-1); |
|
368 | return env.notebook.scroll_manager.scroll(-1); | |
369 | }, |
|
369 | }, | |
370 | }, |
|
370 | }, | |
371 | 'recenter': { |
|
371 | 'scroll-cell-center': { | |
372 |
help: " |
|
372 | help: "Scroll the current cell to the center", | |
373 | handler: function (env, event) { |
|
373 | handler: function (env, event) { | |
374 | if(event){ |
|
374 | if(event){ | |
375 | event.preventDefault(); |
|
375 | event.preventDefault(); | |
376 | } |
|
376 | } | |
377 | var cell = env.notebook.get_selected_index(); |
|
377 | var cell = env.notebook.get_selected_index(); | |
378 |
return env.notebook.scroll_ |
|
378 | return env.notebook.scroll_cell_percent(cell, 50, 0); | |
379 | } |
|
379 | } | |
380 | }, |
|
380 | }, | |
381 | 'top': { |
|
381 | 'scroll-cell-top': { | |
382 |
help: " |
|
382 | help: "Scroll the current cell to the top", | |
383 | handler: function (env, event) { |
|
383 | handler: function (env, event) { | |
384 | if(event){ |
|
384 | if(event){ | |
385 | event.preventDefault(); |
|
385 | event.preventDefault(); | |
386 | } |
|
386 | } | |
387 | var cell = env.notebook.get_selected_index(); |
|
387 | var cell = env.notebook.get_selected_index(); | |
388 |
return env.notebook.scroll_ |
|
388 | return env.notebook.scroll_cell_percent(cell, 0, 0); | |
389 | } |
|
389 | } | |
390 | }, |
|
390 | }, | |
391 | 'save-notebook':{ |
|
391 | 'save-notebook':{ |
@@ -80,8 +80,6 define([ | |||||
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 | 'ctrl-l' : 'ipython.recenter', |
|
|||
84 | 'ctrl-shift-l' : 'ipython.top' |
|
|||
85 | }; |
|
83 | }; | |
86 | }; |
|
84 | }; | |
87 |
|
85 |
@@ -351,34 +351,30 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 | var cells = this.get_cells(); |
|
354 | return this.scroll_cell_percent(index, 0, time); | |
355 | time = time || 0; |
|
|||
356 | index = Math.min(cells.length-1,index); |
|
|||
357 | index = Math.max(0 ,index); |
|
|||
358 | var scroll_value = cells[index].element.position().top-cells[0].element.position().top ; |
|
|||
359 | this.scroll_manager.element.animate({scrollTop:scroll_value}, time); |
|
|||
360 | return scroll_value; |
|
|||
361 | }; |
|
355 | }; | |
362 |
|
356 | |||
363 | /** |
|
357 | /** | |
364 | * Scroll the middle of the page to a given cell. |
|
358 | * Scroll the middle of the page to a given cell. | |
365 | * |
|
359 | * | |
366 | * @param {integer} index - An index of the cell to view |
|
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. | |||
367 | * @param {integer} time - Animation time in milliseconds |
|
363 | * @param {integer} time - Animation time in milliseconds | |
368 | * @return {integer} Pixel offset from the top of the container |
|
364 | * @return {integer} Pixel offset from the top of the container | |
369 | */ |
|
365 | */ | |
370 |
Notebook.prototype.scroll_ |
|
366 | Notebook.prototype.scroll_cell_percent = function (index, percent, time) { | |
371 | var cells = this.get_cells(); |
|
367 | var cells = this.get_cells(); | |
372 | time = time || 0; |
|
368 | time = time || 0; | |
|
369 | percent = percent || 0; | |||
373 | index = Math.min(cells.length-1,index); |
|
370 | index = Math.min(cells.length-1,index); | |
374 | index = Math.max(0 ,index); |
|
371 | index = Math.max(0 ,index); | |
375 | // var scroll_value = cells[index].element.position().top-cells[0].element.position().top ; |
|
|||
376 | var sme = this.scroll_manager.element; |
|
372 | var sme = this.scroll_manager.element; | |
377 | var h = sme.height(); |
|
373 | var h = sme.height(); | |
378 | var st = sme.scrollTop(); |
|
374 | var st = sme.scrollTop(); | |
379 | var t = sme.offset().top; |
|
375 | var t = sme.offset().top; | |
380 | var ct = cells[index].element.offset().top; |
|
376 | var ct = cells[index].element.offset().top; | |
381 |
var scroll_value = st + ct - (t + h |
|
377 | var scroll_value = st + ct - (t + .01 * percent * h); | |
382 | this.scroll_manager.element.animate({scrollTop:scroll_value}, time); |
|
378 | this.scroll_manager.element.animate({scrollTop:scroll_value}, time); | |
383 | return scroll_value; |
|
379 | return scroll_value; | |
384 | }; |
|
380 | }; |
General Comments 0
You need to be logged in to leave comments.
Login now