~svij/calculator/delete-multiple-calculation

« back to all changes in this revision

Viewing changes to app/ui/ScrollableView.qml

  • Committer: Giulio Collura
  • Date: 2014-12-28 14:20:45 UTC
  • mto: This revision was merged to the branch mainline in revision 48.
  • Revision ID: giulio.collura@gmail.com-20141228142045-9825czwzh0nr3sn6
Introduce ScrollableView, fix CMakelists to correctly create click pkgs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.3
 
2
 
 
3
Flickable {
 
4
    id: flickable
 
5
 
 
6
    default property alias data: column.children
 
7
    contentHeight: column.childrenRect.height
 
8
    boundsBehavior: Flickable.DragOverBounds
 
9
 
 
10
    property double initContentY
 
11
 
 
12
    onMovementStarted: {
 
13
        initContentY = contentY;
 
14
    }
 
15
 
 
16
    onMovementEnded: {
 
17
        if (contentY <= 0) {
 
18
            return;
 
19
        }
 
20
        var posy = flickable.height + flickable.visibleArea.yPosition * flickable.contentHeight
 
21
        // FIXME:
 
22
        // It's column.width - units.gu(2) because of the weird alignment of TextField
 
23
        var obj = column.childAt(column.width - units.gu(2), posy)
 
24
        if (Math.abs(posy - obj.y) < obj.height / 2) {
 
25
            console.log("scroll up", obj.y);
 
26
            flickable.contentY = obj.y - flickable.height
 
27
        } else {
 
28
            console.log("scroll down", obj.y);
 
29
            flickable.contentY = obj.y + obj.height - flickable.height
 
30
        }
 
31
    }
 
32
 
 
33
    Behavior on contentY {
 
34
        NumberAnimation { duration: 300; easing.type: Easing.OutQuad}
 
35
    }
 
36
 
 
37
    Column {
 
38
        id: column
 
39
        anchors {
 
40
            left: parent.left
 
41
            right: parent.right
 
42
        }
 
43
        spacing: 0
 
44
    }
 
45
}