/****************************************************************************
 ** ScStw Styling
 ** Copyright (C) 2020  Itsblue development
 **
 ** This program is free software: you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
 ** the Free Software Foundation, either version 3 of the License, or
 ** (at your option) any later version.
 **
 ** This program is distributed in the hope that it will be useful,
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ** GNU General Public License for more details.
 **
 ** You should have received a copy of the GNU General Public License
 ** along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ****************************************************************************/

import QtQuick 2.0

SequentialAnimation {
    id: root
    property QtObject target
    property int fadeDuration: 150
    property int fadeDuration_in: fadeDuration
    property int fadeDuration_out: fadeDuration

    property alias outValueScale: outAnimationScale.to
    property alias inValueScale: inAnimationScale.to

    property alias outValueOpacity: outAnimationOpacity.to
    property alias inValueOpacity: inAnimationOpacity.to

    property string easingType: "Quad"
    ParallelAnimation {
    NumberAnimation { // in the default case, fade scale to 0
        id: outAnimationScale
        target: root.target
        property: "scale"
        duration: root.fadeDuration_in
        to: 0.9
        easing.type: Easing["In"+root.easingType]
    }
    NumberAnimation { // in the default case, fade scale to 0
        id: outAnimationOpacity
        target: root.target
        property: "opacity"
        duration: root.fadeDuration_in
        to: 0
        easing.type: Easing["In"+root.easingType]
    }
    }
    PropertyAction { } // actually change the property targeted by the Behavior between the 2 other animations
    ParallelAnimation {
        NumberAnimation { // in the default case, fade scale back to 1
            id: inAnimationScale
            target: root.target
            property: "scale"
            duration: root.fadeDuration_out
            to: 1
            easing.type: Easing["Out"+root.easingType]
        }
    NumberAnimation { // in the default case, fade scale to 0
        id: inAnimationOpacity
        target: root.target
        property: "opacity"
        duration: root.fadeDuration_in
        to: 1
        easing.type: Easing["In"+root.easingType]
    }
    }

}
