plugins/fullscreen: retarget the animation instead of restarting it

BUG: 474488
FIXED-IN: 6.0
wilder/Plasma/6.2
Xaver Hugl 2 years ago
parent 1a1eaee13f
commit e9db9cd7d3
  1. 74
      src/plugins/fullscreen/package/contents/code/main.js

@ -43,33 +43,55 @@ class FullScreenEffect {
oldGeometry = window.olderGeometry; oldGeometry = window.olderGeometry;
window.olderGeometry = Object.assign({}, window.oldGeometry); window.olderGeometry = Object.assign({}, window.oldGeometry);
window.oldGeometry = Object.assign({}, newGeometry); window.oldGeometry = Object.assign({}, newGeometry);
window.fullScreenAnimation1 = animate({
window: window, let couldRetarget = false;
duration: this.duration, if (window.fullScreenAnimation1) {
animations: [{ if (window.fullScreenAnimation1[0]) {
type: Effect.Size, couldRetarget = retarget(window.fullScreenAnimation1[0], {
to: {
value1: newGeometry.width, value1: newGeometry.width,
value2: newGeometry.height value2: newGeometry.height
}, }, this.duration);
from: { }
value1: oldGeometry.width, if (window.fullScreenAnimation1[1]) {
value2: oldGeometry.height couldRetarget = retarget(window.fullScreenAnimation1[1], {
}, value1: newGeometry.x + newGeometry.width / 2,
curve: QEasingCurve.OutCubic value2: newGeometry.y + newGeometry.height / 2
}, { }, this.duration);
type: Effect.Translation, }
to: { }
value1: 0, if (!couldRetarget) {
value2: 0 if (window.fullScreenAnimation1) {
}, cancel(window.fullScreenAnimation1);
from: { delete window.fullScreenAnimation1;
value1: oldGeometry.x - newGeometry.x - (newGeometry.width / 2 - oldGeometry.width / 2), }
value2: oldGeometry.y - newGeometry.y - (newGeometry.height / 2 - oldGeometry.height / 2) window.fullScreenAnimation1 = animate({
}, window: window,
curve: QEasingCurve.OutCubic 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) { if (!window.resize) {
window.fullScreenAnimation2 =animate({ window.fullScreenAnimation2 =animate({
window: window, window: window,
@ -92,8 +114,6 @@ class FullScreenEffect {
if (window.fullScreenAnimation1) { if (window.fullScreenAnimation1) {
if (window.geometry.width != window.oldGeometry.width || if (window.geometry.width != window.oldGeometry.width ||
window.geometry.height != window.oldGeometry.height) { window.geometry.height != window.oldGeometry.height) {
cancel(window.fullScreenAnimation1);
delete window.fullScreenAnimation1;
if (window.fullScreenAnimation2) { if (window.fullScreenAnimation2) {
cancel(window.fullScreenAnimation2); cancel(window.fullScreenAnimation2);
delete window.fullScreenAnimation2; delete window.fullScreenAnimation2;

Loading…
Cancel
Save