Skip to content

Commit bcef5c5

Browse files
authored
Merge pull request #1561 from adumesny/develop
H5 Safari fix delay when dropping
2 parents ddc34d6 + f32a73f commit bcef5c5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

doc/CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ Change log
4646
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
4747
## 3.1.3-dev
4848

49-
- fix [1557](https://github.com/gridstack/gridstack.js/pull/1557) fixed no-drop cursor on windows when dragging within a default grid (no external drag in)
49+
- fix [1557](https://github.com/gridstack/gridstack.js/pull/1557) fix no-drop cursor on windows when dragging within a default grid (no external drag in)
50+
- fix [1541](https://github.com/gridstack/gridstack.js/pull/1541) fix Safari H5 elay when dropping items
5051

5152
## 3.1.3 (2021-1-2)
5253

src/h5/dd-draggable.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
5656
private helperContainment: HTMLElement;
5757
/** @internal */
5858
private static basePosition: 'fixed' | 'absolute' = 'absolute';
59-
/** @internal */
60-
private static dragEventListenerOption = DDUtils.isEventSupportPassiveOption ? { capture: true, passive: true } : true;
59+
/** @internal #1541 can't have {passive: true} on Safari as otherwise it reverts animate back to old location on drop */
60+
private static dragEventListenerOption = true; // DDUtils.isEventSupportPassiveOption ? { capture: true, passive: true } : true;
6161
/** @internal */
6262
private static originStyleProp = ['transition', 'pointerEvents', 'position',
6363
'left', 'top', 'opacity', 'zIndex', 'width', 'height', 'willChange'];
@@ -164,6 +164,9 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
164164

165165
/** @internal */
166166
private _drag(event: DragEvent): void {
167+
// Safari: prevent default to allow drop to happen instead of reverting back (with animation) and delaying dragend #1541
168+
// https://stackoverflow.com/questions/61760755/how-to-fire-dragend-event-immediately
169+
event.preventDefault();
167170
this._dragFollow(event);
168171
const ev = DDUtils.initEvent<DragEvent>(event, { target: this.el, type: 'drag' });
169172
if (this.option.drag) {

0 commit comments

Comments
 (0)