summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
Diffstat (limited to 'program')
-rw-r--r--program/js/treelist.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/program/js/treelist.js b/program/js/treelist.js
index d6d50e4f7..fec2d7f21 100644
--- a/program/js/treelist.js
+++ b/program/js/treelist.js
@@ -442,8 +442,12 @@ function rcube_treelist_widget(node, p)
*/
function scroll_to_node(li)
{
- var scroller = container.parent();
- scroller.scrollTop(li.offset().top - scroller.offset().top + scroller.scrollTop());
+ var scroller = container.parent(),
+ current_offset = scroller.scrollTop(),
+ rel_offset = li.offset().top - scroller.offset().top;
+
+ if (rel_offset < 0 || rel_offset + li.height() > scroller.height())
+ scroller.scrollTop(rel_offset + current_offset);
}
///// drag & drop support