QGCFlickableHorizontalIndicator.qml 1.49 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

Rectangle {
    id:                    horizontalIndicator
    anchors.bottomMargin:  2
    anchors.bottom:        parent.bottom
    x:                     parent.width * (parent.contentX / parent.contentWidth)
    z:                     10
    height:                2
    width:                 parent.width * (parent.width / parent.contentWidth)
    color:                 parent.indicatorColor
    visible:               showIndicator

14 15 16
    property bool showIndicator: (parent.flickableDirection === Flickable.AutoFlickDirection ||
                                  parent.flickableDirection === Flickable.HorizontalFlick ||
                                  parent.flickableDirection === Flickable.HorizontalAndVerticalFlick) &&
Don Gagne's avatar
Don Gagne committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
                                 (parent.contentWidth > parent.width)

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

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

    NumberAnimation {
        id:            animateOpacity
        target:        horizontalIndicator
        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
    }
}