fix task scrub icon list sometimes being off center

also fix animation duration and easing type not being in sync with task preview list.
fixes https://invent.kde.org/plasma/plasma-mobile/-/issues/392
This commit is contained in:
Luis Büchi 2024-08-01 16:30:23 +00:00
parent 3adcd1d51c
commit a41b386651
2 changed files with 15 additions and 12 deletions

View file

@ -445,20 +445,18 @@ FocusScope {
Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration } }
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.right: parent.horizontalCenter
anchors.bottomMargin: taskSwitcherHelpers.openedYPosition * 5 / 8
anchors.horizontalCenterOffset: {
anchors.rightMargin: {
let size = Kirigami.Units.iconSizes.large + Kirigami.Units.largeSpacing * 2;
let offset = (root.state.currentTaskIndex - 0.5) * size;
return offset;
let offset = (root.state.currentTaskIndex + 0.5) * size;
return -offset;
}
Behavior on anchors.horizontalCenterOffset {
Behavior on anchors.rightMargin {
NumberAnimation {
// TODO: this duration should track the duration of xAnim but that is variable through function parameter
// how do we make sure this is always the same duration?
duration: Kirigami.Units.longDuration * 2;
easing.type: Easing.OutBack;
duration: taskSwitcherHelpers.xAnimDuration;
easing.type: taskSwitcherHelpers.xAnimEasingType;
}
}

View file

@ -37,6 +37,10 @@ QtObject {
// we don't want to continuously send haptics, just once is enough
property bool hasVibrated: false
// made as variables to keep x anim in task list and task scrub icon list in sync
property int xAnimDuration: Kirigami.Units.longDuration * 2
property int xAnimEasingType: Easing.OutExpo
// ~~ measurement constants ~~
// dimensions of a real window on the screen
@ -161,9 +165,9 @@ QtObject {
// go to the task index, animated
function animateGoToTaskIndex(index, duration = Kirigami.Units.longDuration * 2, easing = Easing.OutExpo) {
xAnim.duration = duration;
xAnimDuration = duration;
xAnimEasingType = easing;
xAnim.to = xPositionFromTaskIndex(index);
xAnim.easing.type = easing;
xAnim.restart();
}
@ -219,7 +223,8 @@ QtObject {
property var xAnim: NumberAnimation {
target: root.state
property: "xPosition"
easing.type: Easing.OutBack
duration: xAnimDuration
easing.type: xAnimEasingType
}
property var openAnim: NumberAnimation {