2
* Copyright (C) 2014 Canonical Ltd
4
* This file is part of Ubuntu Calculator App
6
* Ubuntu Calculator App is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 3 as
8
* published by the Free Software Foundation.
10
* Ubuntu Calculator App is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
default property alias data: column.children
24
property double oldContentHeight: 0
25
contentHeight: column.height
26
boundsBehavior: Flickable.DragOverBounds
27
property bool snap: true
30
if (contentY <= 0 || !snap) {
33
var posy = flickable.height + flickable.visibleArea.yPosition * flickable.contentHeight
34
// FIXME see ubuntu-calculator-app:269:
35
// It's column.width - units.gu(2) because of the weird alignment of TextField
36
var obj = column.childAt(column.width - units.gu(2), posy)
37
if (Math.abs(posy - obj.y) < obj.height / 2) {
39
var destY = obj.y - flickable.height;
40
// don't go out of bound
41
if (destY < 0) destY = 0;
42
scrollingAnimation.to = destY;
45
scrollingAnimation.to = obj.y + obj.height - flickable.height;
47
scrollingAnimation.start()
50
NumberAnimation on contentY {
51
id: scrollingAnimation
53
easing.type: Easing.OutQuad
56
function scrollToBottom() {
57
if (column.height > flickable.height) {
58
flickable.contentY = flickable.contentHeight - flickable.height;
65
// scroll to bottom only when something is inserted.
66
if (oldContentHeight < contentHeight) {
67
flickable.scrollToBottom();
69
oldContentHeight = contentHeight;
79
height: flickable.height > column.height ? flickable.height - column.height : 0