[gnome-shell/gbsneto/custom-icon-positions: 7/28] 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: 7/28] appDisplay: Nudge target item towards its new position
- Date: Wed, 15 Jul 2020 20:50:25 +0000 (UTC)
commit 532a3362e54df6930276eb4a587f2adf8ee3edcd
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 | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index a1bfc8669b..0dc7659555 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -570,6 +570,7 @@ class AppDisplay extends BaseAppView {
this._lastOvershootTimeoutId = 0;
this._delayedMoveId = 0;
this._targetDropPosition = null;
+ this._nudgedItem = null;
Main.overview.connect('hidden', () => this.goToPage(0));
@@ -827,6 +828,38 @@ 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_QUAD,
+ };
+
+ 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,
+ duration: DELAYED_MOVE_TIMEOUT,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ });
+ this._nudgedItem = null;
+ }
+
_maybeMoveItem(dragEvent) {
const [success, x, y] =
this._grid.transform_stage_point(dragEvent.x, dragEvent.y);
@@ -842,6 +875,7 @@ class AppDisplay extends BaseAppView {
item === source ||
dragLocation === IconGrid.DragLocation.ON_ICON) {
this._removeDelayedMove();
+ this._removeNudge();
return;
}
@@ -864,10 +898,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);
}
}
@@ -956,6 +993,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]