QGCFlickableVerticalIndicator.qml 1.48 KB
Newer Older
1
import QtQuick 2.3
Don Gagne's avatar
Don Gagne committed
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 32 33 34 35

Rectangle {
    id:                    verticalIndicator
    anchors.rightMargin:   2
    anchors.right:         parent.right
    y:                     parent.height * (parent.contentY / parent.contentHeight)
    z:                     10
    width:                 2
    height:                parent.height * (parent.height / parent.contentHeight)
    color:                 parent.indicatorColor
    visible:               showIndicator

    property bool showIndicator: (parent.flickableDirection == Flickable.AutoFlickDirection ||
                                  parent.flickableDirection == Flickable.VerticalFlick ||
                                  parent.flickableDirection == Flickable.HorizontalAndVerticalFlick) &&
                                 (parent.contentHeight > parent.height)

    Component.onCompleted:  animateOpacity.restart()
    onVisibleChanged:       animateOpacity.restart()
    onHeightChanged:        animateOpacity.restart()

    Connections {
        target:                    verticalIndicator.parent
        onMovementStarted:         verticalIndicator.opacity = 1.0
        onMovementEnded:           animateOpacity.restart()
        onContentHeightChanged:    animateOpacity.restart()
    }

    NumberAnimation {
        id:            animateOpacity
        target:        verticalIndicator
        properties:    "opacity"
        from:          1.0
        to:            0.0
36
        duration:      3000
Don Gagne's avatar
Don Gagne committed
37 38 39
        easing.type:   Easing.InQuint
    }
}