Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
Showable.qml
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// SPDX-License-Identifier: MPL-2.0
3
4import QtQuick
5
13FocusScope {
14 id: root
15 Accessible.ignored: true
19 property var showAnimation
20
24 property var hideAnimation
25 visible: false
26 onHideAnimationChanged: {
27 // Automatically set animation target when it's possible
28 if (showAnimation && showAnimation.target != undefined)
29 showAnimation.target = root;
30 if (hideAnimation && hideAnimation.target != undefined)
31 hideAnimation.target = root;
32
33 // Hide the item when the animation is over
34 if (hideAnimation) {
35 hideAnimation.runningChanged.connect(function () {
36 if (!hideAnimation.running)
37 root.visible = false;
38 });
39 }
40 }
41
45 function show() {
46 // Stop hide animation if it's still running
47 if (hideAnimation != undefined && hideAnimation.running)
48 hideAnimation.stop();
49
50 // Show the item otherwise we won't see the animation
51 visible = true;
52
53 // Restart show animation if available
54 if (showAnimation != undefined && !showAnimation.running)
55 showAnimation.restart();
56 }
57
61 function hide() {
62 // Stop show animation if it's still running
63 if (showAnimation != undefined && showAnimation.running)
64 showAnimation.stop();
65
66 // Restart hide animation if available
67 if (hideAnimation != undefined && !hideAnimation.running)
68 hideAnimation.restart();
69 }
70}