Last active
August 29, 2015 14:00
-
-
Save jdfreder/e2bf6c6c6beadf0a4477 to your computer and use it in GitHub Desktop.
Space and shift-space H1 scrolling in the notebook.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%javascript | |
window.hcell = 0; | |
var delta_header_scroll = function(delta) { | |
window.hcell += delta; | |
var $h1cells = $('h1 a'); | |
window.hcell = Math.max(0, Math.min($h1cells.length-1, window.hcell)); | |
setTimeout(function(){$h1cells[window.hcell].scrollIntoView(true);}, 0); | |
}; | |
IPython.keyboard_manager.command_shortcuts.add_shortcuts({ | |
'space': { | |
help: "Scroll down to next H1 cell", | |
handler: function(event) { | |
delta_header_scroll(1); | |
}, | |
}, | |
'shift-space': { | |
help: "Scroll up to previous H1 cell", | |
handler: function(event) { | |
delta_header_scroll(-1); | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment