From 17b4bed1b8b590ad5fb6eef8d284d1a66d9443d0 2015-04-08 17:15:20
From: Min RK <benjaminrk@gmail.com>
Date: 2015-04-08 17:15:20
Subject: [PATCH] address code review

- remove ctrl shortcuts for scrolling
- rename scroll actions 'scroll-cell-center', 'scroll-cell-top'
- rename added notebook method `scroll_cell_percent`

---

diff --git a/IPython/html/static/notebook/js/actions.js b/IPython/html/static/notebook/js/actions.js
index 5848be5..245f4ec 100644
--- a/IPython/html/static/notebook/js/actions.js
+++ b/IPython/html/static/notebook/js/actions.js
@@ -368,24 +368,24 @@ define(function(require){
                 return env.notebook.scroll_manager.scroll(-1);
             },
         },
-        'recenter': {
-            help: "Move the current cell to the center",
+        'scroll-cell-center': {
+            help: "Scroll the current cell to the center",
             handler: function (env, event) {
                 if(event){
                     event.preventDefault();
                 }
                 var cell = env.notebook.get_selected_index();
-                return env.notebook.scroll_middle_to_cell(cell, 0);
+                return env.notebook.scroll_cell_percent(cell, 50, 0);
             }
         },
-        'top': {
-            help: "Move the current cell to the top",
+        'scroll-cell-top': {
+            help: "Scroll the current cell to the top",
             handler: function (env, event) {
                 if(event){
                     event.preventDefault();
                 }
                 var cell = env.notebook.get_selected_index();
-                return env.notebook.scroll_to_cell(cell, 0);
+                return env.notebook.scroll_cell_percent(cell, 0, 0);
             }
         },
         'save-notebook':{
diff --git a/IPython/html/static/notebook/js/keyboardmanager.js b/IPython/html/static/notebook/js/keyboardmanager.js
index c29fc3f..e1a3eab 100644
--- a/IPython/html/static/notebook/js/keyboardmanager.js
+++ b/IPython/html/static/notebook/js/keyboardmanager.js
@@ -80,8 +80,6 @@ define([
             'down'                : 'ipython.move-cursor-down-or-next-cell',
             'ctrl-shift--'        : 'ipython.split-cell-at-cursor',
             'ctrl-shift-subtract' : 'ipython.split-cell-at-cursor',
-            'ctrl-l'              : 'ipython.recenter',
-            'ctrl-shift-l'        : 'ipython.top'
         };
     };
 
diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js
index 37e4361..19ae227 100644
--- a/IPython/html/static/notebook/js/notebook.js
+++ b/IPython/html/static/notebook/js/notebook.js
@@ -351,34 +351,30 @@ define(function (require) {
      * @return {integer} Pixel offset from the top of the container
      */
     Notebook.prototype.scroll_to_cell = function (index, time) {
-        var cells = this.get_cells();
-        time = time || 0;
-        index = Math.min(cells.length-1,index);
-        index = Math.max(0             ,index);
-        var scroll_value = cells[index].element.position().top-cells[0].element.position().top ;
-        this.scroll_manager.element.animate({scrollTop:scroll_value}, time);
-        return scroll_value;
+        return this.scroll_cell_percent(index, 0, time);
     };
 
     /**
      * Scroll the middle of the page to a given cell.
      *
      * @param {integer}  index - An index of the cell to view
+     * @param {integer}  percent - 0-100, the location on the screen to scroll.
+     *                   0 is the top, 100 is the bottom.
      * @param {integer}  time - Animation time in milliseconds
      * @return {integer} Pixel offset from the top of the container
      */
-    Notebook.prototype.scroll_middle_to_cell = function (index, time) {
+    Notebook.prototype.scroll_cell_percent = function (index, percent, time) {
         var cells = this.get_cells();
         time = time || 0;
+        percent = percent || 0;
         index = Math.min(cells.length-1,index);
         index = Math.max(0             ,index);
-        // var scroll_value = cells[index].element.position().top-cells[0].element.position().top ;
         var sme = this.scroll_manager.element;
         var h = sme.height();
         var st = sme.scrollTop();
         var t = sme.offset().top;
         var ct = cells[index].element.offset().top;
-        var scroll_value =  st + ct - (t + h/2);
+        var scroll_value =  st + ct - (t + .01 * percent * h);
         this.scroll_manager.element.animate({scrollTop:scroll_value}, time);
         return scroll_value;
     };