react-dnd-touch-backend
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -19,4 +19,2 @@ /** | ||
var _reactDndModulesUtilsOffsetHelpers = require('react-dnd/modules/utils/OffsetHelpers'); | ||
var _invariant = require('invariant'); | ||
@@ -26,2 +24,25 @@ | ||
function getEventClientOffset(e) { | ||
return { | ||
x: e.clientX, | ||
y: e.clientY | ||
}; | ||
} | ||
var ELEMENT_NODE = 1; | ||
function getNodeClientOffset(node) { | ||
var el = node.nodeType === ELEMENT_NODE ? node : node.parentElement; | ||
if (!el) { | ||
return null; | ||
} | ||
var _el$getBoundingClientRect = el.getBoundingClientRect(); | ||
var top = _el$getBoundingClientRect.top; | ||
var left = _el$getBoundingClientRect.left; | ||
return { x: left, y: top }; | ||
} | ||
var TouchBackend = (function () { | ||
@@ -124,3 +145,3 @@ function TouchBackend(manager) { | ||
value: function getSourceClientOffset(sourceId) { | ||
return (0, _reactDndModulesUtilsOffsetHelpers.getElementClientOffset)(this.sourceNodes[sourceId]); | ||
return getNodeClientOffset(this.sourceNodes[sourceId]); | ||
} | ||
@@ -149,3 +170,3 @@ }, { | ||
this._mouseClientOffset = (0, _reactDndModulesUtilsOffsetHelpers.getEventClientOffset)(e.targetTouches[0]); | ||
this._mouseClientOffset = getEventClientOffset(e.targetTouches[0]); | ||
} | ||
@@ -163,3 +184,3 @@ }, { | ||
var clientOffset = (0, _reactDndModulesUtilsOffsetHelpers.getEventClientOffset)(e.targetTouches[0]); | ||
var clientOffset = getEventClientOffset(e.targetTouches[0]); | ||
@@ -166,0 +187,0 @@ // If we're not dragging and we've moved a little, that counts as a drag start |
{ | ||
"name": "react-dnd-touch-backend", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Touch backend for react-dnd", | ||
@@ -8,3 +8,3 @@ "main": "dist/Touch.js", | ||
"prepublish": "gulp dist", | ||
"test": "gulp lint" | ||
"test": "gulp clean lint" | ||
}, | ||
@@ -11,0 +11,0 @@ "repository": { |
@@ -0,2 +1,9 @@ | ||
<img src="https://avatars2.githubusercontent.com/u/6412038?v=3&s=200" alt="react logo" title="react" align="right" width="64" height="64" /> | ||
# react-dnd-touch-backend | ||
[![npm version](https://badge.fury.io/js/react-dnd-touch-backend.svg)](http://badge.fury.io/js/react-dnd-touch-backend) | ||
[![Dependency Status](https://david-dm.org/yahoo/react-dnd-touch-backend.svg)](https://david-dm.org/yahoo/react-dnd-touch-backend) | ||
[![devDependency Status](https://david-dm.org/yahoo/react-dnd-touch-backend/dev-status.svg)](https://david-dm.org/yahoo/react-dnd-touch-backend#info=devDependencies) | ||
Touch Backend for [react-dnd](https://github.com/gaearon/react-dnd) | ||
@@ -3,0 +10,0 @@ |
@@ -7,5 +7,25 @@ /** | ||
import { getElementClientOffset, getEventClientOffset } from 'react-dnd/modules/utils/OffsetHelpers'; | ||
import invariant from 'invariant'; | ||
function getEventClientOffset (e) { | ||
return { | ||
x: e.clientX, | ||
y: e.clientY | ||
}; | ||
} | ||
const ELEMENT_NODE = 1; | ||
function getNodeClientOffset (node) { | ||
const el = node.nodeType === ELEMENT_NODE | ||
? node | ||
: node.parentElement; | ||
if (!el) { | ||
return null; | ||
} | ||
const { top, left } = el.getBoundingClientRect(); | ||
return { x: left, y: top }; | ||
} | ||
export class TouchBackend { | ||
@@ -93,3 +113,3 @@ constructor (manager) { | ||
getSourceClientOffset (sourceId) { | ||
return getElementClientOffset(this.sourceNodes[sourceId]); | ||
return getNodeClientOffset(this.sourceNodes[sourceId]); | ||
} | ||
@@ -96,0 +116,0 @@ |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
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
36849
9
406
31
1