Comparing version 2.2.1 to 2.2.2
@@ -27,2 +27,3 @@ import React from "react"; | ||
waitingMove: boolean; | ||
listening: boolean; | ||
onPointerDown: (e: React.MouseEvent<Element, MouseEvent> | React.TouchEvent<Element>) => void; | ||
@@ -33,8 +34,7 @@ addListeners(e: React.MouseEvent | React.TouchEvent): void; | ||
onMouseMove: (e: MouseEvent) => void; | ||
onMouseEnd: (e?: MouseEvent) => void; | ||
onTouchMove: (e: TouchEvent) => void; | ||
onTouchEnd: (e?: TouchEvent) => void; | ||
onDragEnd: (e?: MouseEvent | TouchEvent) => void; | ||
onKeyDown: (e?: KeyboardEvent) => void; | ||
cleanup(e: DragManager.DragState): void; | ||
onEnd(): void; | ||
removeListeners(): void; | ||
cleanup(state: DragManager.DragState): void; | ||
render(): React.ReactNode; | ||
@@ -41,0 +41,0 @@ componentWillUnmount(): void; |
@@ -44,2 +44,4 @@ "use strict"; | ||
this.dragType = null; | ||
this.waitingMove = false; | ||
this.listening = false; | ||
this.onPointerDown = (e) => { | ||
@@ -79,18 +81,2 @@ if (!DragManager.checkPointerDownEvent(e.nativeEvent)) { | ||
}; | ||
this.onMouseEnd = (e) => { | ||
let { onDragEndT } = this.props; | ||
let state = new DragManager.DragState(e, this); | ||
document.removeEventListener('mousemove', this.onMouseMove); | ||
document.removeEventListener('mouseup', this.onMouseEnd); | ||
this.cleanup(state); | ||
if (!this.waitingMove) { | ||
if (e) { | ||
state.onDrop(); | ||
} | ||
if (onDragEndT) { | ||
onDragEndT(state); | ||
} | ||
} | ||
DragManager.destroyDraggingElement(state); | ||
}; | ||
this.onTouchMove = (e) => { | ||
@@ -104,3 +90,3 @@ let { onDragMoveT } = this.props; | ||
else if (e.touches.length !== 1) { | ||
this.onTouchEnd(); | ||
this.onDragEnd(); | ||
} | ||
@@ -116,8 +102,6 @@ else { | ||
}; | ||
this.onTouchEnd = (e) => { | ||
this.onDragEnd = (e) => { | ||
let { onDragEndT } = this.props; | ||
let state = new DragManager.DragState(e, this); | ||
document.removeEventListener('touchmove', this.onTouchMove); | ||
document.removeEventListener('touchend', this.onTouchEnd); | ||
this.cleanup(state); | ||
this.removeListeners(); | ||
if (!this.waitingMove) { | ||
@@ -131,7 +115,7 @@ if (e) { | ||
} | ||
DragManager.destroyDraggingElement(state); | ||
this.cleanup(state); | ||
}; | ||
this.onKeyDown = (e) => { | ||
if (e.key === 'Escape') { | ||
this.onEnd(); | ||
this.onDragEnd(); | ||
} | ||
@@ -142,8 +126,8 @@ }; | ||
let { onDragStartT } = this.props; | ||
if (this.dragType) { | ||
this.onEnd(); | ||
if (this.listening) { | ||
this.onDragEnd(); | ||
} | ||
if (e.nativeEvent.type === 'touchstart') { | ||
document.addEventListener('touchmove', this.onTouchMove); | ||
document.addEventListener('touchend', this.onTouchEnd); | ||
document.addEventListener('touchend', this.onDragEnd); | ||
this.dragType = 'touch'; | ||
@@ -153,3 +137,3 @@ } | ||
document.addEventListener('mousemove', this.onMouseMove); | ||
document.addEventListener('mouseup', this.onMouseEnd); | ||
document.addEventListener('mouseup', this.onDragEnd); | ||
if (e.nativeEvent.button === 2) { | ||
@@ -164,2 +148,3 @@ this.dragType = 'right'; | ||
this.waitingMove = true; | ||
this.listening = true; | ||
} | ||
@@ -180,3 +165,3 @@ // return true for a valid move | ||
if (!DragManager.isDragging()) { | ||
this.onEnd(); | ||
this.onDragEnd(); | ||
return false; | ||
@@ -188,16 +173,20 @@ } | ||
} | ||
cleanup(e) { | ||
this.dragType = null; | ||
this.waitingMove = false; | ||
document.body.classList.remove('dock-dragging'); | ||
document.removeEventListener('keydown', this.onKeyDown); | ||
} | ||
onEnd() { | ||
removeListeners() { | ||
if (this.dragType === 'touch') { | ||
this.onTouchEnd(); | ||
document.removeEventListener('touchmove', this.onTouchMove); | ||
document.removeEventListener('touchend', this.onDragEnd); | ||
} | ||
else { | ||
this.onMouseEnd(); | ||
document.removeEventListener('mousemove', this.onMouseMove); | ||
document.removeEventListener('mouseup', this.onDragEnd); | ||
} | ||
document.body.classList.remove('dock-dragging'); | ||
document.removeEventListener('keydown', this.onKeyDown); | ||
this.listening = false; | ||
} | ||
cleanup(state) { | ||
this.dragType = null; | ||
this.waitingMove = false; | ||
DragManager.destroyDraggingElement(state); | ||
} | ||
render() { | ||
@@ -224,4 +213,4 @@ let _a = this.props, { getRef, children, className, directDragT, onDragStartT, onDragMoveT, onDragEndT, onDragOverT, onDragLeaveT, onDropT } = _a, others = __rest(_a, ["getRef", "children", "className", "directDragT", "onDragStartT", "onDragMoveT", "onDragEndT", "onDragOverT", "onDragLeaveT", "onDropT"]); | ||
} | ||
if (this.dragType) { | ||
this.onEnd(); | ||
if (this.listening) { | ||
this.onDragEnd(); | ||
} | ||
@@ -228,0 +217,0 @@ } |
{ | ||
"name": "rc-dock", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "dock layout for react component", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
568245
8447