Skip to content

Commit 004493a

Browse files
committed
DnD Snap to Animation fix
fix for #1973 * added a timeout > 0 to reset animation back so values have a chance to render...
1 parent c1b5a75 commit 004493a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

doc/CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Change log
55
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
66
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
77

8+
- [5.1.0-dev (TBD)](#510-dev-tbd)
89
- [5.1.0 (2022-05-21)](#510-2022-05-21)
910
- [5.0.0 (2022-01-10)](#500-2022-01-10)
1011
- [4.4.1 (2021-12-24)](#441-2021-12-24)
@@ -67,6 +68,8 @@ Change log
6768

6869
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
6970

71+
## 5.1.0-dev (TBD)
72+
* fix v5.1.0 regression [#1973](https://github.com/gridstack/gridstack.js/issues/1973) DnD Snap to Animation
7073

7174
## 5.1.0 (2022-05-21)
7275
* add `GridStack.registerEngine()` to let user use their own custom layout engine subclass. Thank you [Thomas] for sponsoring it.

src/h5/dd-draggable.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
236236
// don't bother restoring styles if we're gonna remove anyway...
237237
if (this.dragElementOriginStyle && (!node || !node._isAboutToRemove)) {
238238
let helper = this.helper;
239-
DDDraggable.originStyleProp.forEach(prop => helper.style[prop] = this.dragElementOriginStyle[prop] || null);
240-
// show up instantly otherwise we animate to off the grid when switching back to 'absolute' from 'fixed'
241-
helper.style.transition = 'none';
239+
// don't animate, otherwise we animate offseted when switching back to 'absolute' from 'fixed'
242240
let transition = this.dragElementOriginStyle['transition'] || null;
243-
setTimeout(() => helper.style.transition = transition, 0); // recover animation from saved vars
241+
helper.style.transition = this.dragElementOriginStyle['transition'] = 'none';
242+
DDDraggable.originStyleProp.forEach(prop => helper.style[prop] = this.dragElementOriginStyle[prop] || null);
243+
setTimeout(() => helper.style.transition = transition, 50); // recover animation from saved vars after a pause (0 isn't enough #1973)
244244
}
245245
delete this.dragElementOriginStyle;
246246
return this;

0 commit comments

Comments
 (0)