Skip to content
This repository was archived by the owner on Aug 13, 2018. It is now read-only.

Commit 65e7223

Browse files
committed
#27 ensure visible selected row (during key navigation)
1 parent be6ffd9 commit 65e7223

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

data/components/frame-list.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,25 @@ var FrameList = React.createClass({
3434
return { data: [] };
3535
},
3636

37+
componentDidUpdate: function() {
38+
var bubble = document.querySelector(".frameBubble.selected");
39+
if (bubble) {
40+
this.ensureVisible(bubble);
41+
}
42+
},
43+
44+
ensureVisible: function(bubble) {
45+
var content = document.querySelector(".mainPanelContent");
46+
47+
if (bubble.offsetTop < content.scrollTop) {
48+
content.scrollTop = bubble.offsetTop - 45; // minus padding
49+
}
50+
51+
if (bubble.offsetTop + bubble.offsetHeight > content.scrollTop + content.clientHeight) {
52+
content.scrollTop = bubble.offsetTop + bubble.offsetHeight - content.clientHeight;
53+
}
54+
},
55+
3756
render: function() {
3857
var { frames, summary, filter } = this.props.frames;
3958
frames = filter.frames || frames;

data/components/frame-table.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ var FrameTable = React.createClass({
2828

2929
displayName: "FrameTable",
3030

31+
componentDidUpdate: function() {
32+
var row = document.querySelector(".frameRow.selected");
33+
if (row) {
34+
this.ensureVisible(row);
35+
}
36+
},
37+
38+
ensureVisible: function(row) {
39+
var content = document.querySelector(".mainPanelContent");
40+
41+
if (row.offsetTop < content.scrollTop) {
42+
content.scrollTop = row.offsetTop;
43+
}
44+
45+
if (row.offsetTop + row.offsetHeight > content.scrollTop + content.clientHeight) {
46+
content.scrollTop = row.offsetTop + row.offsetHeight - content.clientHeight;
47+
}
48+
},
49+
3150
render: function() {
3251
var {frames, summary, filter} = this.props.frames;
3352
frames = filter.frames || frames;

0 commit comments

Comments
 (0)