Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion release/internal/drag-operation-controller.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export declare class DragOperationController {
private _iterationIntervalId;
constructor(_initialEvent: TouchEvent, _config: Config, _sourceNode: HTMLElement, _dragOperationEndedCb: (config: Config, event: TouchEvent, state: DragOperationState) => void);
private _setup();
private _cleanup();
cleanup();
private _onTouchMove(event);
private _onTouchEndOrCancel(event);
private _dragAndDropProcessModelIteration();
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ function onTouchstart( e:TouchEvent ) {
// only allow one drag operation at a time
if( activeDragOperation ) {
console.log( "dnd-poly: drag operation already active" );
// try avoid infinite loop on iOS if something happened with draggable dom object (disappeared or changed during drag)
activeDragOperation.cleanup();
return;
}

Expand Down
10 changes: 5 additions & 5 deletions src/internal/drag-operation-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class DragOperationController {
console.log( "dnd-poly: dragstart cancelled" );
// dragstart has been prevented -> cancel d'n'd
this._dragOperationState = DragOperationState.CANCELLED;
this._cleanup();
this.cleanup();
return false;
}

Expand Down Expand Up @@ -245,7 +245,7 @@ export class DragOperationController {
return true;
}

private _cleanup() {
public cleanup() {

console.log( "dnd-poly: cleanup" );

Expand Down Expand Up @@ -304,7 +304,7 @@ export class DragOperationController {

if( !startDrag ) {

this._cleanup();
this.cleanup();
return;
}

Expand Down Expand Up @@ -398,7 +398,7 @@ export class DragOperationController {

// drag operation did not even start
if( this._dragOperationState === DragOperationState.POTENTIAL ) {
this._cleanup();
this.cleanup();
return;
}

Expand Down Expand Up @@ -796,7 +796,7 @@ export class DragOperationController {

// drag operation over and out
this._dragOperationState = DragOperationState.ENDED;
this._cleanup();
this.cleanup();
}

//</editor-fold>
Expand Down
32 changes: 23 additions & 9 deletions src/internal/feature-detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,29 @@ export function detectFeatures():DetectedFeatures {
userAgentSupportingNativeDnD: undefined
};

const isBlinkEngine = !!((<any>window).chrome) || /chrome/i.test( navigator.userAgent );

features.userAgentSupportingNativeDnD = !(
// if is mobile safari or android browser -> no native dnd
(/iPad|iPhone|iPod|Android/.test( navigator.userAgent ))
|| // OR
//if is blink(chrome/opera) with touch events enabled -> no native dnd
(isBlinkEngine && ("ontouchstart" in document.documentElement))
);
// const isBlinkEngine = !!((<any>window).chrome) || /chrome/i.test( navigator.userAgent );

// features.userAgentSupportingNativeDnD = !(
// // if is mobile safari or android browser -> no native dnd
// (/iPad|iPhone|iPod|Android/.test( navigator.userAgent ))
// || // OR
// //if is blink(chrome/opera) with touch events enabled -> no native dnd
// (isBlinkEngine && ("ontouchstart" in document.documentElement))
// );

if (/iPad|iPhone|iPod/.test(navigator.userAgent)) {
// from iOS 11 and higher are supported
features.userAgentSupportingNativeDnD = !/(OS \d_)|(OS 10_)/.test(navigator.userAgent);
}
else
if (/Android/.test(navigator.userAgent)) {
// from Chrome Mobile 54 and higher are supported
features.userAgentSupportingNativeDnD = !/(Chrome\/5[0-3]\.)|(Chrome\/[1-4]\d\.)|(Chrome\/\d\.)/.test(navigator.userAgent);
}
else {
// should work on all ten years old desktop browsers and younger
features.userAgentSupportingNativeDnD = true;
}

return features;
}
Expand Down