[gnome-shell/wip/swarm: 3/11] SwarmAnimation f
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/swarm: 3/11] SwarmAnimation f
- Date: Wed, 25 Jun 2014 17:45:24 +0000 (UTC)
commit 7d863305e1da034909d82993f0c5ea2676889367
Author: Carlos Soriano <carlos soriano89 gmail com>
Date: Wed Jun 25 19:40:09 2014 +0200
SwarmAnimation f
js/ui/appDisplay.js | 19 +++++++++++--------
js/ui/iconGrid.js | 23 ++++++++++++++++-------
2 files changed, 27 insertions(+), 15 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index f296659..8274aba 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -443,15 +443,17 @@ const AllView = new Lang.Class({
animate: function(animationDirection, onCompleteOut) {
let dashPosition = Main.overview._dash._showAppsIcon.get_transformed_position();
let dashSize = Main.overview._dash._showAppsIcon.get_transformed_size();
+ let centerDashPosition = [dashPosition[0] + dashSize[0] / 2, dashPosition[1] + dashSize[1] / 2];
// Design decision, 1/2 of the dash icon size.
let dashScaledSize = [dashSize[0] / 2, dashSize[1] / 2];
- let gridAnimationFunction = Lang.bind(this, function() {
- this._grid.animate(IconGrid.ANIMATION_TYPE_SWARM_SPRING,
- animationDirection,
- { sourcePosition: dashPosition,
- sourceSize: dashScaledSize,
- page: this._currentPage })
- });
+ let gridAnimationFunction = Lang.bind(this,
+ function() {
+ this._grid.animate(IconGrid.ANIMATION_TYPE_SWARM_SPRING,
+ animationDirection,
+ { sourcePosition: centerDashPosition,
+ sourceSize: dashScaledSize,
+ page: this._currentPage })
+ });
if (animationDirection == IconGrid.ANIMATION_DIRECTION_IN) {
let toAnimate = this._grid.actor.connect('notify::allocation', Lang.bind(this,
function() {
@@ -725,12 +727,13 @@ const FrequentView = new Lang.Class({
animate: function(animationDirection, onCompleteOut) {
let dashPosition = Main.overview._dash._showAppsIcon.get_transformed_position();
let dashSize = Main.overview._dash._showAppsIcon.get_transformed_size();
+ let centerDashPosition = [dashPosition[0] + dashSize[0] / 2, dashPosition[1] + dashSize[1] / 2];
// Design decision, 1/2 of the dash icon size.
let dashScaledSize = [dashSize[0] / 2, dashSize[1] / 2];
let gridAnimationFunction = Lang.bind(this, function() {
this._grid.animate(IconGrid.ANIMATION_TYPE_SWARM_SPRING,
animationDirection,
- { sourcePosition: dashPosition,
+ { sourcePosition: centerDashPosition,
sourceSize: dashScaledSize });
});
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 92bb403..158b90f 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -450,21 +450,31 @@ const IconGrid = new Lang.Class({
reactive: false });
Main.uiGroup.add_actor(actorClone);
- actorClone.set_pivot_point(0.5, 0.5);
- let scaleX = sourceSize[0] / actors[index].get_transformed_size()[0];
- let scaleY = sourceSize[1] / actors[index].get_transformed_size()[1];
+ actorClone.set_pivot_point(0.0, 0.0);
let [width, height] = actors[index].get_transformed_size();
actorClone.set_size(width, height);
+ let scaleX = sourceSize[0] / width;
+ let scaleY = sourceSize[1] / height;
// Defeat onComplete anonymous function closure
let actor = actors[index];
let isLastItem = index == actors.length - 1;
let movementParams, fadeParams;
+
+ // Center the actor on the source position, expecting sourcePosition to be the center
+ // where the actor should be. In this way we avoid misaligments if the source actor size changes
+ // or is diferent that it should be. (hint: for the AllView and FrequentView animations the
+ // sourceSize is not exactly the actor size, since we want smaller actors to be animated due to
+ // design decision)
+ let adjustedSourcePosition = [sourcePosition[0] - sourceSize[0] / 2, sourcePosition[1] -
sourceSize[1] / 2];
+
if (animationDirection == ANIMATION_DIRECTION_IN) {
- actorClone.set_position(sourcePosition[0], sourcePosition[1]);
actorClone.opacity = 0;
actorClone.set_scale(scaleX, scaleY);
+
+ actorClone.set_position(adjustedSourcePosition[0], adjustedSourcePosition[1]);
+
let delay = (1 - (distances[index] - minDist) / normalization) *
ANIMATION_MAX_DELAY_FOR_ITEM;
let [finalX, finalY] = actors[index].get_transformed_position();
movementParams = { time: ANIMATION_TIME_IN,
@@ -491,12 +501,11 @@ const IconGrid = new Lang.Class({
actorClone.set_position(startX, startY);
let delay = (distances[index] - minDist) / normalization * ANIMATION_MAX_DELAY_OUT_FOR_ITEM;
- let [finalX, finalY] = [sourcePosition[0], sourcePosition[1]];
movementParams = { time: ANIMATION_TIME_OUT,
transition: 'easeInOutQuad',
delay: delay,
- x: finalX,
- y: finalY,
+ x: adjustedSourcePosition[0],
+ y: adjustedSourcePosition[1],
scale_x: scaleX,
scale_y: scaleY,
onComplete: Lang.bind(this, function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]