2
* Copyright (C) 2016 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
import Ubuntu.Components 1.3
19
import Unity.Application 0.1
20
import "MathUtils.js" as MathUtils
26
property int itemIndex: 0
27
property int normalZ: 0
28
property real progress: 0
29
property int startWidth: 0
30
property int startHeight: 0
31
property int startX: 0
32
property int targetX: 0
33
property int startY: 0
34
property int targetY: 0
35
// property real startAngle: 40
36
property real targetAngle: 0
37
property int targetHeight: 0
38
property real targetScale: 0
41
property real breakPoint: 0.4
45
readonly property real scaleToPreviewProgress: {
46
return progress < breakPoint ? 0 : MathUtils.clamp(MathUtils.linearAnimation(breakPoint, 1, 0, 1, progress), 0, 1)
48
readonly property int animatedWidth: {
49
return progress < breakPoint ? root.startWidth : MathUtils.linearAnimation(breakPoint, 1, root.startWidth, targetHeight, progress)
52
readonly property int animatedHeight: {
53
return progress < breakPoint ? root.startHeight : MathUtils.linearAnimation(breakPoint, 1, root.startHeight, targetHeight, progress)
56
readonly property int animatedX: {
57
if (progress < breakPoint) {
60
return MathUtils.linearAnimation(breakPoint, 1, startX, targetX, progress)
63
readonly property int animatedY: progress < breakPoint ? startY : MathUtils.linearAnimation(breakPoint, 1, startY, targetY, progress)
65
readonly property real animatedAngle: progress < breakPoint ? 0 : MathUtils.linearAnimation(breakPoint, 1, 0, targetAngle, progress);
67
readonly property real decorationHeight: progress < breakPoint ? 1 : MathUtils.linearAnimation(breakPoint, 1, 1, 0, progress);
69
readonly property int animatedZ: {
70
if (progress < breakPoint + (1 - breakPoint) / 2) {
71
return itemIndex == 1 ? normalZ + 2 : normalZ
76
readonly property real opacityMask: itemIndex == 1 ? MathUtils.linearAnimation(0, breakPoint, 0, 1, progress) : 1
78
readonly property real animatedScale: progress < breakPoint ? 1 : MathUtils.linearAnimation(breakPoint, 1, 1, targetScale, progress)
80
// readonly property bool itemVisible: true //animatedX < sceneWidth