From 2897ec000a55f832a4032a64c8f9de8dd7e370f0 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 31 Aug 2015 19:53:49 +0200 Subject: Improve scrolling to items larger than the viewport --- src/list/TerminalList.qml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/list/TerminalList.qml b/src/list/TerminalList.qml index 9c1636f..cafefeb 100644 --- a/src/list/TerminalList.qml +++ b/src/list/TerminalList.qml @@ -37,12 +37,17 @@ Item { function scrollTo(index) { if ( column.height >= flickable.height ) { - var offset = children[index].y - + (children[index].height / 2) - - (flickable.height / 2); + var offset = children[index].y; + + if ( children[index].height > flickable.height ) { + offset -= (flickable.height / 2); + } else { + offset += (children[index].height / 2) + - (flickable.height / 2); + } var bound = column.height - - flickable.height; + - flickable.height; if ( offset < 0 ) { flickable.contentY = 0; -- cgit v1.2.3