mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	scroll_util: Add support for sticky headers.
When calculating position of an element, we now take into account the height of the sticky headers too.
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user