[gnome-shell/gbsneto/custom-icon-positions: 5/20] appDisplay: Nudge target item towards its new position
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/custom-icon-positions: 5/20] appDisplay: Nudge target item towards its new position
- Date: Tue, 23 Jun 2020 18:44:24 +0000 (UTC)
commit 0758cc593d2d20d775f40a8d78b2223d9f68bd26
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Jun 22 18:46:59 2020 -0300
appDisplay: Nudge target item towards its new position
Make the icon being hovered slightly nudge towards its final
position, some sort of "preview" of what will happen. This
avoids a surprising change of the grid.
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1284
js/ui/appDisplay.js | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index dbeac0967e..a611b88e48 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -36,7 +36,7 @@ const FOLDER_DIALOG_ANIMATION_TIME = 200;
const OVERSHOOT_THRESHOLD = 20;
const OVERSHOOT_TIMEOUT = 1000;
-const DELAYED_MOVE_TIMEOUT = 1500;
+const DELAYED_MOVE_TIMEOUT = 750;
let discreteGpuAvailable = false;
@@ -563,6 +563,7 @@ class AppDisplay extends BaseAppView {
this._lastOvershootTimeoutId = 0;
this._delayedMoveId = 0;
this._targetDropPosition = null;
+ this._nudgedItem = null;
Main.overview.connect('hidden', () => this.goToPage(0));
@@ -820,6 +821,37 @@ class AppDisplay extends BaseAppView {
this._targetDropPosition = null;
}
+ _nudgeItem(item, dragLocation) {
+ if (this._nudgedItem)
+ this._removeNudge();
+
+ const params = {
+ duration: DELAYED_MOVE_TIMEOUT,
+ mode: Clutter.AnimationMode.EASE_IN_OUT_CUBIC,
+ };
+
+ const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
+ const nudgeOffset = item.width / 4;
+ if (dragLocation === IconGrid.DragLocation.START_EDGE)
+ params.translation_x = nudgeOffset * (rtl ? -1 : 1);
+ else if (dragLocation === IconGrid.DragLocation.END_EDGE)
+ params.translation_x = -nudgeOffset * (rtl ? -1 : 1);
+
+ item.ease(params);
+ this._nudgedItem = item;
+ }
+
+ _removeNudge() {
+ if (!this._nudgedItem)
+ return;
+
+ this._nudgedItem.ease({
+ translation_x: 0,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ });
+ this._nudgedItem = null;
+ }
+
_maybeMoveItem(dragEvent) {
const [success, x, y] =
this._grid.transform_stage_point(dragEvent.x, dragEvent.y);
@@ -835,6 +867,7 @@ class AppDisplay extends BaseAppView {
item === source ||
dragLocation === IconGrid.DragLocation.ON_ICON) {
this._removeDelayedMove();
+ this._removeNudge();
return;
}
@@ -850,10 +883,13 @@ class AppDisplay extends BaseAppView {
this._delayedMoveId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
DELAYED_MOVE_TIMEOUT, () => {
this.moveItem(source, page, position);
+ this._removeNudge();
this._targetDropPosition = null;
this._delayedMoveId = 0;
return GLib.SOURCE_REMOVE;
});
+
+ this._nudgeItem(item, dragLocation);
}
}
@@ -942,6 +978,7 @@ class AppDisplay extends BaseAppView {
}
this._resetOvershoot();
+ this._removeNudge();
}
_canAccept(source) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]