~dalius-sandbox/ubuntu-calculator-app/minor-bug-fixes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import QtQuick 2.0

Flickable {
    id: keyboardsView
    width: parent.width
    clip: true

    contentWidth: stdKeyboard.width
    contentHeight: stdKeyboard.height

    property double buttonRowHeight: units.gu(8);
    property double targetPosition
 
    onMovementEnded: {
       var stopPositionInRow = contentY % buttonRowHeight;
       if( Math.abs(stopPositionInRow) > (buttonRowHeight/2)) {
            targetPosition = contentY+(buttonRowHeight - stopPositionInRow)
       }
       else {
            targetPosition = contentY -stopPositionInRow
       }
       snap.start();
    }

    NumberAnimation {id: snap; target: keyboardsView; property: "contentY"; to: targetPosition }

    StdKeyboard {
        id: stdKeyboard
        width: keyboardsView.width
    }
}