You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
157 lines
4.8 KiB
JavaScript
157 lines
4.8 KiB
JavaScript
/*
|
|
This file is part of the KDE project.
|
|
|
|
SPDX-FileCopyrightText: 2021 Reven Martin <revenmartin@gmail.com>
|
|
SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var squashEffect = {
|
|
duration: animationTime(300),
|
|
loadConfig: function () {
|
|
squashEffect.duration = animationTime(300);
|
|
},
|
|
slotWindowMinimized: function (window) {
|
|
if (effects.hasActiveFullScreenEffect) {
|
|
return;
|
|
}
|
|
|
|
// If the window doesn't have an icon in the task manager,
|
|
// don't animate it.
|
|
var iconRect = window.iconGeometry;
|
|
if (iconRect.width == 0 || iconRect.height == 0) {
|
|
return;
|
|
}
|
|
|
|
if (window.unminimizeAnimation) {
|
|
if (redirect(window.unminimizeAnimation, Effect.Backward)) {
|
|
return;
|
|
}
|
|
cancel(window.unminimizeAnimation);
|
|
delete window.unminimizeAnimation;
|
|
}
|
|
|
|
if (window.minimizeAnimation) {
|
|
if (redirect(window.minimizeAnimation, Effect.Forward)) {
|
|
return;
|
|
}
|
|
cancel(window.minimizeAnimation);
|
|
}
|
|
|
|
var windowRect = window.geometry;
|
|
|
|
window.minimizeAnimation = animate({
|
|
window: window,
|
|
curve: QEasingCurve.OutQuad, //OutQuad, InOutQuad
|
|
duration: squashEffect.duration,
|
|
animations: [
|
|
{
|
|
type: Effect.Size,
|
|
from: {
|
|
value1: windowRect.width,
|
|
value2: windowRect.height
|
|
},
|
|
to: {
|
|
value1: iconRect.width,
|
|
value2: iconRect.height
|
|
}
|
|
},
|
|
{
|
|
type: Effect.Translation,
|
|
from: {
|
|
value1: 0.0,
|
|
value2: 0.0
|
|
},
|
|
to: {
|
|
value1: iconRect.x - windowRect.x -
|
|
(windowRect.width - iconRect.width) / 2,
|
|
value2: iconRect.y - windowRect.y -
|
|
(windowRect.height - iconRect.height) / 2,
|
|
}
|
|
},
|
|
{
|
|
type: Effect.Opacity,
|
|
from: 1.0,
|
|
to: 1.0
|
|
}
|
|
]
|
|
});
|
|
},
|
|
slotWindowUnminimized: function (window) {
|
|
if (effects.hasActiveFullScreenEffect) {
|
|
return;
|
|
}
|
|
|
|
// If the window doesn't have an icon in the task manager,
|
|
// don't animate it.
|
|
var iconRect = window.iconGeometry;
|
|
if (iconRect.width == 0 || iconRect.height == 0) {
|
|
return;
|
|
}
|
|
|
|
if (window.minimizeAnimation) {
|
|
if (redirect(window.minimizeAnimation, Effect.Backward)) {
|
|
return;
|
|
}
|
|
cancel(window.minimizeAnimation);
|
|
delete window.minimizeAnimation;
|
|
}
|
|
|
|
if (window.unminimizeAnimation) {
|
|
if (redirect(window.unminimizeAnimation, Effect.Forward)) {
|
|
return;
|
|
}
|
|
cancel(window.unminimizeAnimation);
|
|
}
|
|
|
|
var windowRect = window.geometry;
|
|
|
|
window.unminimizeAnimation = animate({
|
|
window: window,
|
|
curve: QEasingCurve.InOutQuad, // QEasingCurve.OutSine,
|
|
duration: squashEffect.duration,
|
|
animations: [
|
|
{
|
|
type: Effect.Size,
|
|
from: {
|
|
value1: iconRect.width,
|
|
value2: iconRect.height
|
|
},
|
|
to: {
|
|
value1: windowRect.width,
|
|
value2: windowRect.height
|
|
}
|
|
},
|
|
{
|
|
type: Effect.Translation,
|
|
from: {
|
|
value1: iconRect.x - windowRect.x -
|
|
(windowRect.width - iconRect.width) / 2,
|
|
value2: iconRect.y - windowRect.y -
|
|
(windowRect.height - iconRect.height) / 2,
|
|
},
|
|
to: {
|
|
value1: 0.0,
|
|
value2: 0.0
|
|
}
|
|
},
|
|
{
|
|
type: Effect.Opacity,
|
|
from: 1.0,
|
|
to: 1.0
|
|
}
|
|
]
|
|
});
|
|
},
|
|
init: function () {
|
|
effect.configChanged.connect(squashEffect.loadConfig);
|
|
effects.windowMinimized.connect(squashEffect.slotWindowMinimized);
|
|
effects.windowUnminimized.connect(squashEffect.slotWindowUnminimized);
|
|
}
|
|
};
|
|
|
|
squashEffect.init();
|