[gnome-shell] iconGrid.js: Animate icon spring using translation
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] iconGrid.js: Animate icon spring using translation
- Date: Mon, 13 Jan 2020 13:43:01 +0000 (UTC)
commit 76961927d56dcc92be5d77ecfabdb1b2d176db0e
Author: Daniel van Vugt <daniel van vugt canonical com>
Date: Fri Jan 10 17:37:26 2020 +0800
iconGrid.js: Animate icon spring using translation
Animating the icon spring using the `translation-x/y` properties instead
of the `x/y` properties avoids relayouts. There are still other non-icon
actors moving, but it's a big improvement.
Before: 595 relayouts per spring
After: 94 relayouts per spring
Reducing relayouts reduces reallocation, which reduces CPU-intensive
JavaScript execution.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/926
js/ui/iconGrid.js | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 11ea0a7f92..0495bd0893 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -557,14 +557,14 @@ var IconGrid = GObject.registerClass({
actorClone.opacity = 0;
actorClone.set_scale(scaleX, scaleY);
-
- actorClone.set_position(adjustedSourcePositionX, adjustedSourcePositionY);
+ actorClone.set_translation(
+ adjustedSourcePositionX, adjustedSourcePositionY, 0);
let delay = (1 - (actor._distance - minDist) / normalization) * ANIMATION_MAX_DELAY_FOR_ITEM;
let [finalX, finalY] = actor._transformedPosition;
movementParams = {
- x: finalX,
- y: finalY,
+ translation_x: finalX,
+ translation_y: finalY,
scale_x: 1,
scale_y: 1,
duration: ANIMATION_TIME_IN,
@@ -585,12 +585,12 @@ var IconGrid = GObject.registerClass({
let isLastItem = actor._distance == maxDist;
let [startX, startY] = actor._transformedPosition;
- actorClone.set_position(startX, startY);
+ actorClone.set_translation(startX, startY, 0);
let delay = (actor._distance - minDist) / normalization * ANIMATION_MAX_DELAY_OUT_FOR_ITEM;
movementParams = {
- x: adjustedSourcePositionX,
- y: adjustedSourcePositionY,
+ translation_x: adjustedSourcePositionX,
+ translation_y: adjustedSourcePositionY,
scale_x: scaleX,
scale_y: scaleY,
duration: ANIMATION_TIME_OUT,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]