Skip to content

Commit 800af8d

Browse files
authored
Merge pull request #1181 from jcb91/scroll_down
[scroll_down] fix 5.x compatibility
2 parents 579ed5d + 6ca314a commit 800af8d

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

src/jupyter_contrib_nbextensions/nbextensions/scroll_down/config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ Description: Scroll outputs down automatically
44
Link: readme.md
55
Icon: icon.png
66
Main: main.js
7-
Compatibility: 4.x
7+
Compatibility: 4.x, 5.x
8+
Parameters:
9+
- name: scrollDownIsEnabled
10+
description: enable scroll_down toolbar button
11+
input_type: checkbox
12+
default: false

src/jupyter_contrib_nbextensions/nbextensions/scroll_down/main.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ define([
2323
}
2424

2525
function setButtonColor() {
26-
var bg = params.scrollDownIsEnabled ? "darkgray" : "";
27-
$("#toggle_scroll_down").css("background-color", bg);
26+
$("#toggle_scroll_down").toggleClass('active', params.scrollDownIsEnabled);
2827
}
2928

3029
function load_extension() {
@@ -34,16 +33,17 @@ define([
3433
icon : 'fa-angle-double-down ',
3534
handler: toggleScrollDown
3635
}, 'toggle-auto-scroll-down', 'scroll_down')
37-
])).find('.btn').attr('id', 'toggle_runtools');
36+
])).find('.btn').attr('id', 'toggle_scroll_down');
3837

3938
console.log("[ScrollDown] is loaded");
4039

41-
$(".output").on("resize", function () {
40+
// the event was renamed from 'resize' to 'resizeOutput' in
41+
// https://github.com/jupyter/notebook/commit/b4928d481abd9f7cd996fd4b24078a55880d21e6
42+
$(".output").on("resize resizeOutput", function () {
4243
if (!params.scrollDownIsEnabled) return;
4344
var output = $(this);
4445
setTimeout(function () {
4546
output.scrollTop(output.prop("scrollHeight"));
46-
console.log("height: " + output.prop("scrollHeight"));
4747
}, 0);
4848
});
4949

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
# ScrollDown
22

3-
When enabled, scrolls cells' outputs down automatically.
3+
When enabled, this nbextension scrolls cells' outputs down automatically as
4+
they are enlarged. It can be enabled and disabled using the toolbar button:
5+
6+
![](icon.png)
7+
8+
9+
Options
10+
-------
11+
12+
The enabled status is toggleable with the toolbar button, which sets the option
13+
option `scrollDownIsEnabled` in the notebook config section.

0 commit comments

Comments
 (0)