dnd: Make DND translation-property-aware
Previously DND only worked properly for actors with zero translation. But it only requires a small tweak to `this._dragOffsetX/Y` to support non-zero translation values. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/936
This commit is contained in:
parent
141652b7ec
commit
881eab7669
12
js/ui/dnd.js
12
js/ui/dnd.js
@ -411,14 +411,18 @@ var _Draggable = class _Draggable {
|
|||||||
this._snapBackY = this._dragStartY + this._dragOffsetY;
|
this._snapBackY = this._dragStartY + this._dragOffsetY;
|
||||||
this._snapBackScale = this._dragActor.scale_x;
|
this._snapBackScale = this._dragActor.scale_x;
|
||||||
|
|
||||||
|
let origDragOffsetX = this._dragOffsetX;
|
||||||
|
let origDragOffsetY = this._dragOffsetY;
|
||||||
|
let [transX, transY] = this._dragActor.get_translation();
|
||||||
|
this._dragOffsetX -= transX;
|
||||||
|
this._dragOffsetY -= transY;
|
||||||
|
|
||||||
if (this._dragActorMaxSize != undefined) {
|
if (this._dragActorMaxSize != undefined) {
|
||||||
let [scaledWidth, scaledHeight] = this._dragActor.get_transformed_size();
|
let [scaledWidth, scaledHeight] = this._dragActor.get_transformed_size();
|
||||||
let currentSize = Math.max(scaledWidth, scaledHeight);
|
let currentSize = Math.max(scaledWidth, scaledHeight);
|
||||||
if (currentSize > this._dragActorMaxSize) {
|
if (currentSize > this._dragActorMaxSize) {
|
||||||
let scale = this._dragActorMaxSize / currentSize;
|
let scale = this._dragActorMaxSize / currentSize;
|
||||||
let origScale = this._dragActor.scale_x;
|
let origScale = this._dragActor.scale_x;
|
||||||
let origDragOffsetX = this._dragOffsetX;
|
|
||||||
let origDragOffsetY = this._dragOffsetY;
|
|
||||||
|
|
||||||
// The position of the actor changes as we scale
|
// The position of the actor changes as we scale
|
||||||
// around the drag position, but we can't just tween
|
// around the drag position, but we can't just tween
|
||||||
@ -435,8 +439,8 @@ var _Draggable = class _Draggable {
|
|||||||
|
|
||||||
this._dragActor.get_transition('scale-x').connect('new-frame', () => {
|
this._dragActor.get_transition('scale-x').connect('new-frame', () => {
|
||||||
let currentScale = this._dragActor.scale_x / origScale;
|
let currentScale = this._dragActor.scale_x / origScale;
|
||||||
this._dragOffsetX = currentScale * origDragOffsetX;
|
this._dragOffsetX = currentScale * origDragOffsetX - transX;
|
||||||
this._dragOffsetY = currentScale * origDragOffsetY;
|
this._dragOffsetY = currentScale * origDragOffsetY - transY;
|
||||||
this._dragActor.set_position(
|
this._dragActor.set_position(
|
||||||
this._dragX + this._dragOffsetX,
|
this._dragX + this._dragOffsetX,
|
||||||
this._dragY + this._dragOffsetY);
|
this._dragY + this._dragOffsetY);
|
||||||
|
Loading…
Reference in New Issue
Block a user