mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
Prevent the page from jumping on tree tab change
This commit is contained in:
parent
420fee5e4c
commit
ab1fca9fdb
@ -140,8 +140,19 @@ require([
|
|||||||
});
|
});
|
||||||
|
|
||||||
// set hash on tab click
|
// set hash on tab click
|
||||||
$("#tabs").find("a").click(function() {
|
$("#tabs").find("a").click(function(e) {
|
||||||
window.location.hash = $(this).attr("href");
|
// Prevent the document from jumping when the active tab is changed to a
|
||||||
|
// tab that has a lot of content.
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Set the hash without causing the page to jump.
|
||||||
|
// http://stackoverflow.com/a/14690177/2824256
|
||||||
|
var hash = $(this).attr("href");
|
||||||
|
if(window.history.pushState) {
|
||||||
|
window.history.pushState(null, null, hash);
|
||||||
|
} else {
|
||||||
|
window.location.hash = hash;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// load tab if url hash
|
// load tab if url hash
|
||||||
|
Loading…
Reference in New Issue
Block a user