react-dnd-touch-backend
Advanced tools
Comparing version 0.3.4 to 0.3.5
@@ -81,2 +81,5 @@ /** | ||
end: 'touchend' | ||
}, | ||
keyboard: { | ||
keydown: 'keydown' | ||
} | ||
@@ -96,2 +99,3 @@ }; | ||
enableMouseEvents: false, | ||
enableKeyboardEvents: false, | ||
delayTouchStart: 0, | ||
@@ -105,2 +109,3 @@ delayMouseStart: 0 | ||
this.enableKeyboardEvents = options.enableKeyboardEvents; | ||
this.delayTouchStart = options.delayTouchStart; | ||
@@ -124,2 +129,6 @@ this.delayMouseStart = options.delayMouseStart; | ||
if (options.enableKeyboardEvents) { | ||
this.listenerTypes.push('keyboard'); | ||
} | ||
this.getSourceClientOffset = this.getSourceClientOffset.bind(this); | ||
@@ -132,2 +141,3 @@ this.handleTopMoveStart = this.handleTopMoveStart.bind(this); | ||
this.handleTopMoveEndCapture = this.handleTopMoveEndCapture.bind(this); | ||
this.handleCancelOnEscape = this.handleCancelOnEscape.bind(this); | ||
} | ||
@@ -150,2 +160,6 @@ | ||
this.addEventListener(window, 'end', this.handleTopMoveEndCapture, true); | ||
if (this.enableKeyboardEvents) { | ||
this.addEventListener(window, 'keydown', this.handleCancelOnEscape, true); | ||
} | ||
} | ||
@@ -168,2 +182,6 @@ }, { | ||
if (this.enableKeyboardEvents) { | ||
this.removeEventListener(window, 'keydown', this.handleCancelOnEscape, true); | ||
} | ||
this.uninstallSourceNodeRemovalObserver(); | ||
@@ -378,2 +396,12 @@ } | ||
}, { | ||
key: 'handleCancelOnEscape', | ||
value: function handleCancelOnEscape(e) { | ||
if (e.key === "Escape") { | ||
this._mouseClientOffset = {}; | ||
this.uninstallSourceNodeRemovalObserver(); | ||
this.actions.endDrag(); | ||
} | ||
} | ||
}, { | ||
key: 'installSourceNodeRemovalObserver', | ||
@@ -380,0 +408,0 @@ value: function installSourceNodeRemovalObserver(node) { |
{ | ||
"name": "react-dnd-touch-backend", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "Touch backend for react-dnd", | ||
@@ -5,0 +5,0 @@ "main": "dist/Touch.js", |
@@ -60,2 +60,5 @@ /** | ||
end: 'touchend' | ||
}, | ||
keyboard: { | ||
keydown: 'keydown', | ||
} | ||
@@ -71,2 +74,3 @@ }; | ||
enableMouseEvents: false, | ||
enableKeyboardEvents: false, | ||
delayTouchStart: 0, | ||
@@ -81,2 +85,3 @@ delayMouseStart: 0, | ||
this.enableKeyboardEvents = options.enableKeyboardEvents; | ||
this.delayTouchStart = options.delayTouchStart; | ||
@@ -100,2 +105,6 @@ this.delayMouseStart = options.delayMouseStart; | ||
if (options.enableKeyboardEvents) { | ||
this.listenerTypes.push('keyboard') | ||
} | ||
this.getSourceClientOffset = this.getSourceClientOffset.bind(this); | ||
@@ -108,2 +117,3 @@ this.handleTopMoveStart = this.handleTopMoveStart.bind(this); | ||
this.handleTopMoveEndCapture = this.handleTopMoveEndCapture.bind(this); | ||
this.handleCancelOnEscape = this.handleCancelOnEscape.bind(this); | ||
} | ||
@@ -119,7 +129,11 @@ | ||
this.addEventListener(window, 'start', this.getTopMoveStartHandler()); | ||
this.addEventListener(window, 'start', this.handleTopMoveStartCapture, true); | ||
this.addEventListener(window, 'move', this.handleTopMove); | ||
this.addEventListener(window, 'move', this.handleTopMoveCapture, true); | ||
this.addEventListener(window, 'end', this.handleTopMoveEndCapture, true); | ||
this.addEventListener(window, 'start', this.getTopMoveStartHandler()); | ||
this.addEventListener(window, 'start', this.handleTopMoveStartCapture, true); | ||
this.addEventListener(window, 'move', this.handleTopMove); | ||
this.addEventListener(window, 'move', this.handleTopMoveCapture, true); | ||
this.addEventListener(window, 'end', this.handleTopMoveEndCapture, true); | ||
if (this.enableKeyboardEvents){ | ||
this.addEventListener(window, 'keydown', this.handleCancelOnEscape, true); | ||
} | ||
} | ||
@@ -141,2 +155,6 @@ | ||
if (this.enableKeyboardEvents){ | ||
this.removeEventListener(window, 'keydown', this.handleCancelOnEscape, true); | ||
} | ||
this.uninstallSourceNodeRemovalObserver(); | ||
@@ -340,2 +358,11 @@ } | ||
handleCancelOnEscape (e) { | ||
if (e.key === "Escape"){ | ||
this._mouseClientOffset = {}; | ||
this.uninstallSourceNodeRemovalObserver(); | ||
this.actions.endDrag(); | ||
} | ||
} | ||
installSourceNodeRemovalObserver (node) { | ||
@@ -342,0 +369,0 @@ this.uninstallSourceNodeRemovalObserver(); |
Sorry, the diff of this file is too big to display
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
103936
1469