зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1416394 - Scroll row into view using scrollIntoView. r=Honza
MozReview-Commit-ID: KoTvLkZA3CL --HG-- extra : rebase_source : 28128b633633ecc2d5d25a017bd9cda36c9bb009
This commit is contained in:
Родитель
648ac7cb6d
Коммит
a78a4d5525
|
@ -289,19 +289,7 @@ define(function (require, exports, module) {
|
|||
this.setState(Object.assign({}, this.state, {
|
||||
selected: row.id
|
||||
}));
|
||||
|
||||
// If the top or bottom side of the row is not visible and there is available space
|
||||
// beyond the opposite one, then attempt to scroll the hidden side into view, but
|
||||
// without hiding the visible side.
|
||||
let scroller = scrollContainer(row);
|
||||
if (!scroller) {
|
||||
return;
|
||||
}
|
||||
let scrollToTop = row.offsetTop;
|
||||
let scrollToBottom = scrollToTop + row.offsetHeight - scroller.offsetHeight;
|
||||
let max = Math.max(scrollToTop, scrollToBottom);
|
||||
let min = Math.min(scrollToTop, scrollToBottom);
|
||||
scroller.scrollTop = Math.max(min, Math.min(max, scroller.scrollTop));
|
||||
row.scrollIntoView({block: "nearest"});
|
||||
}
|
||||
|
||||
isSelected(nodePath) {
|
||||
|
@ -516,18 +504,6 @@ define(function (require, exports, module) {
|
|||
return typeof value == "string" && value.length > 50;
|
||||
}
|
||||
|
||||
function scrollContainer(element) {
|
||||
let parent = element.parentElement;
|
||||
let window = element.ownerDocument.defaultView;
|
||||
if (!parent || !window) {
|
||||
return null;
|
||||
}
|
||||
if (window.getComputedStyle(parent).overflowY != "visible") {
|
||||
return parent;
|
||||
}
|
||||
return scrollContainer(parent);
|
||||
}
|
||||
|
||||
// Exports from this module
|
||||
module.exports = TreeView;
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче