Skip to content

Commit 2943cae

Browse files
author
p01
committed
Cleaned the scroll into view of the highlighted resource
1 parent a0ebc74 commit 2943cae

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/resource-manager/resource_service.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,14 @@ cls.ResourceInspector = function(network_logger)
279279

280280
// scroll into view
281281
var container = this.tree_view.get_container().firstChild;
282-
var e_top = e.offsetTop;
283-
var e_bottom = e_top + e.offsetHeight;
284-
var container_top = container.scrollTop;
285-
var container_height = container.offsetHeight;
286-
287-
if (e_top < container_top)
288-
container.scrollTop = e_top;
289-
else if (e_bottom > container_top + container_height)
290-
container.scrollTop = e_bottom - container_height;
282+
var y = container.scrollTop;
283+
var max_y = e.offsetTop;
284+
var min_y = max_y + e.offsetHeight - container.offsetHeight;
285+
286+
if (y < min_y)
287+
container.scrollTop = min_y;
288+
else if (y > max_y)
289+
container.scrollTop = max_y;
291290
}
292291
}.bind(this);
293292

0 commit comments

Comments
 (0)