Skip to content

Commit 581dd70

Browse files
authored
Merge pull request #2011 from adumesny/master
more mobile fixes: `isTouch` was true on Win10
2 parents 496e1f8 + 7a2922c commit 581dd70

File tree

7 files changed

+20
-15
lines changed

7 files changed

+20
-15
lines changed

demo/nested.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ <h1>Nested grids demo</h1>
7171
id: 'main',
7272
children: [
7373
{x:0, y:0, content: 'regular item'},
74-
{x:1, w:4, h:4, subGrid: {children: sub1, id:'sub1_grid', class: 'sub1', ...subOptions}},
75-
{x:5, w:3, h:4, subGrid: {children: sub2, id:'sub2_grid', class: 'sub2', ...subOptions}},
74+
{x:1, y:0, w:4, h:4, subGrid: {children: sub1, id:'sub1_grid', class: 'sub1', ...subOptions}},
75+
{x:5, y:0, w:3, h:4, subGrid: {children: sub2, id:'sub2_grid', class: 'sub2', ...subOptions}},
7676
]
7777
};
7878

src/gridstack-dd.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* eslint-disable @typescript-eslint/no-unused-vars */
77
import { GridStackDDI } from './gridstack-ddi';
88
import { GridItemHTMLElement, GridStackNode, GridStackElement, DDUIData, DDDragInOpt, GridStackPosition } from './types';
9-
import { GridStack, MousePosition } from './gridstack';
9+
import { GridStack } from './gridstack';
1010
import { Utils } from './utils';
1111

1212
/** Drag&Drop drop options */
@@ -273,7 +273,7 @@ GridStack.prototype._setupAcceptWidget = function(this: GridStack): GridStack {
273273
Utils.copyPos(node, this._readAttr(this.placeholder)); // placeholder values as moving VERY fast can throw things off #1578
274274
Utils.removePositioningStyles(el);// @ts-ignore
275275
this._writeAttr(el, node);
276-
this.el.appendChild(el);// @ts-ignore
276+
this.el.appendChild(el);// @ts-ignore // TODO: now would be ideal time to _removeHelperStyle() overriding floating styles (native only)
277277
this._updateContainerHeight();
278278
this.engine.addedNodes.push(node);// @ts-ignore
279279
this._triggerAddEvent();// @ts-ignore
@@ -413,16 +413,15 @@ GridStack.prototype._prepareDragDropByNode = function(this: GridStack, node: Gri
413413
delete node.el;
414414
el.remove();
415415
} else {
416-
if (!node._temporaryRemoved) {
417-
// move to new placeholder location
418-
Utils.removePositioningStyles(target);// @ts-ignore
419-
this._writePosAttr(target, node);
420-
} else {
416+
Utils.removePositioningStyles(target);
417+
if (node._temporaryRemoved) {
421418
// got removed - restore item back to before dragging position
422-
Utils.removePositioningStyles(target);
423419
Utils.copyPos(node, node._orig);// @ts-ignore
424420
this._writePosAttr(target, node);
425421
this.engine.addNode(node);
422+
} else {
423+
// move to new placeholder location
424+
this._writePosAttr(target, node);
426425
}
427426
if (this._gsEventHandler[event.type]) {
428427
this._gsEventHandler[event.type](event, target);

src/gridstack.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $animation_speed: .3s !default;
2929
}
3030

3131
.grid-stack-placeholder > .placeholder-content {
32-
border: 1px dashed lightgray;
32+
background-color: rgba(0,0,0,0.1);
3333
margin: 0;
3434
position: absolute;
3535
width: auto;

src/h5/dd-draggable.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
199199
}
200200
if (this.dragging) {
201201
delete this.dragging;
202+
203+
// reset the drop target if dragging over ourself (already parented, just moving during stop callback below)
204+
if (DDManager.dropElement?.el === this.el.parentElement) {
205+
delete DDManager.dropElement;
206+
}
207+
202208
this.helper.classList.remove('ui-draggable-dragging');
203209
this.helperContainment.style.position = this.parentOriginStylePosition || null;
204210
if (this.helper === this.el) {
@@ -210,7 +216,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
210216
if (this.option.stop) {
211217
this.option.stop(ev); // NOTE: destroy() will be called when removing item, so expect NULL ptr after!
212218
}
213-
this.triggerEvent('stop', ev);
219+
this.triggerEvent('dragstop', ev);
214220

215221
// call the droppable method to receive the item
216222
if (DDManager.dropElement) {

src/h5/dd-droppable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt
136136
}
137137
}
138138

139-
/** item is being dropped on us - called byt the drag mouseup handler - this calls the client drop event */
139+
/** item is being dropped on us - called by the drag mouseup handler - this calls the client drop event */
140140
public drop(e: MouseEvent): void {
141141
e.preventDefault();
142142
const ev = DDUtils.initEvent<DragEvent>(e, { target: this.el, type: 'drop' });

src/h5/dd-resizable-handle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class DDResizableHandle {
9898
/** @internal */
9999
protected _mouseUp(e: MouseEvent): void {
100100
if (this.moving) {
101-
this._triggerEvent('stop', e);
101+
this._triggerEvent('resizestop', e);
102102
}
103103
document.removeEventListener('mousemove', this._mouseMove, true);
104104
document.removeEventListener('mouseup', this._mouseUp);

src/h5/touch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { DDManager } from "./dd-manager";
1010
*/
1111
export const isTouch: boolean = ( 'ontouchstart' in document
1212
|| 'ontouchstart' in window
13-
|| !!window.TouchEvent
13+
// || !!window.TouchEvent // true on Windows 10 Chrome desktop so don't use this
1414
|| ((window as any).DocumentTouch && document instanceof (window as any).DocumentTouch)
1515
|| navigator.maxTouchPoints > 0
1616
|| (navigator as any).msMaxTouchPoints > 0

0 commit comments

Comments
 (0)