From e9db9cd7d3a4bc6b1845b5004cd3a1bd165a5ff9 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Fri, 15 Dec 2023 16:21:16 +0100 Subject: [PATCH] plugins/fullscreen: retarget the animation instead of restarting it BUG: 474488 FIXED-IN: 6.0 --- .../fullscreen/package/contents/code/main.js | 74 ++++++++++++------- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/src/plugins/fullscreen/package/contents/code/main.js b/src/plugins/fullscreen/package/contents/code/main.js index 8219dab13b..ed3b958149 100644 --- a/src/plugins/fullscreen/package/contents/code/main.js +++ b/src/plugins/fullscreen/package/contents/code/main.js @@ -43,33 +43,55 @@ class FullScreenEffect { oldGeometry = window.olderGeometry; window.olderGeometry = Object.assign({}, window.oldGeometry); window.oldGeometry = Object.assign({}, newGeometry); - window.fullScreenAnimation1 = animate({ - window: window, - duration: this.duration, - animations: [{ - type: Effect.Size, - to: { + + let couldRetarget = false; + if (window.fullScreenAnimation1) { + if (window.fullScreenAnimation1[0]) { + couldRetarget = retarget(window.fullScreenAnimation1[0], { value1: newGeometry.width, value2: newGeometry.height - }, - from: { - value1: oldGeometry.width, - value2: oldGeometry.height - }, - curve: QEasingCurve.OutCubic - }, { - type: Effect.Translation, - to: { - value1: 0, - value2: 0 - }, - from: { - value1: oldGeometry.x - newGeometry.x - (newGeometry.width / 2 - oldGeometry.width / 2), - value2: oldGeometry.y - newGeometry.y - (newGeometry.height / 2 - oldGeometry.height / 2) - }, - curve: QEasingCurve.OutCubic - }] - }); + }, this.duration); + } + if (window.fullScreenAnimation1[1]) { + couldRetarget = retarget(window.fullScreenAnimation1[1], { + value1: newGeometry.x + newGeometry.width / 2, + value2: newGeometry.y + newGeometry.height / 2 + }, this.duration); + } + } + if (!couldRetarget) { + if (window.fullScreenAnimation1) { + cancel(window.fullScreenAnimation1); + delete window.fullScreenAnimation1; + } + window.fullScreenAnimation1 = animate({ + window: window, + duration: this.duration, + animations: [{ + type: Effect.Size, + to: { + value1: newGeometry.width, + value2: newGeometry.height + }, + from: { + value1: oldGeometry.width, + value2: oldGeometry.height + }, + curve: QEasingCurve.OutCubic + }, { + type: Effect.Position, + to: { + value1: newGeometry.x + newGeometry.width / 2, + value2: newGeometry.y + newGeometry.height / 2 + }, + from: { + value1: oldGeometry.x + oldGeometry.width / 2, + value2: oldGeometry.y + oldGeometry.height / 2 + }, + curve: QEasingCurve.OutCubic + }] + }); + } if (!window.resize) { window.fullScreenAnimation2 =animate({ window: window, @@ -92,8 +114,6 @@ class FullScreenEffect { if (window.fullScreenAnimation1) { if (window.geometry.width != window.oldGeometry.width || window.geometry.height != window.oldGeometry.height) { - cancel(window.fullScreenAnimation1); - delete window.fullScreenAnimation1; if (window.fullScreenAnimation2) { cancel(window.fullScreenAnimation2); delete window.fullScreenAnimation2;