diff --git a/static/js/scroll_util.js b/static/js/scroll_util.js index f81ae30a22..7275068121 100644 --- a/static/js/scroll_util.js +++ b/static/js/scroll_util.js @@ -20,20 +20,21 @@ export function scroll_delta(opts) { return delta; } -export function scroll_element_into_container($elem, $container) { +export function scroll_element_into_container($elem, $container, sticky_header_height = 0) { // This does the minimum amount of scrolling that is needed to make // the element visible. It doesn't try to center the element, so // this will be non-intrusive to users when they already have // the element visible. $container = ui.get_scroll_element($container); - const elem_top = $elem.position().top; + const elem_top = $elem.position().top - sticky_header_height; const elem_bottom = elem_top + $elem.innerHeight(); + const container_height = $container.height() - sticky_header_height; const opts = { elem_top, elem_bottom, - container_height: $container.height(), + container_height, }; const delta = scroll_delta(opts);