Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vx/drag

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vx/drag - npm Package Compare versions

Comparing version 0.0.179 to 0.0.182

184

build/Drag.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,33 +6,45 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _event = require("@vx/event");
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _propTypes = _interopRequireDefault(require("prop-types"));
var _event = require('@vx/event');
var _react = _interopRequireDefault(require("react"));
var _propTypes = require('prop-types');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _propTypes2 = _interopRequireDefault(_propTypes);
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var _react = require('react');
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
var _react2 = _interopRequireDefault(_react);
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Drag = function (_React$Component) {
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
var Drag =
/*#__PURE__*/
function (_React$Component) {
_inherits(Drag, _React$Component);
function Drag(props) {
var _this;
_classCallCheck(this, Drag);
var _this = _possibleConstructorReturn(this, (Drag.__proto__ || Object.getPrototypeOf(Drag)).call(this, props));
_this = _possibleConstructorReturn(this, _getPrototypeOf(Drag).call(this, props));
_this.state = {

@@ -45,5 +57,5 @@ x: undefined,

};
_this.dragEnd = _this.dragEnd.bind(_this);
_this.dragMove = _this.dragMove.bind(_this);
_this.dragStart = _this.dragStart.bind(_this);
_this.dragEnd = _this.dragEnd.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.dragMove = _this.dragMove.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.dragStart = _this.dragStart.bind(_assertThisInitialized(_assertThisInitialized(_this)));
return _this;

@@ -53,13 +65,13 @@ }

_createClass(Drag, [{
key: 'dragStart',
key: "dragStart",
value: function dragStart(event) {
var _props = this.props,
onDragStart = _props.onDragStart,
resetOnStart = _props.resetOnStart;
var _state = this.state,
dx = _state.dx,
dy = _state.dy;
var _this$props = this.props,
onDragStart = _this$props.onDragStart,
resetOnStart = _this$props.resetOnStart;
var _this$state = this.state,
dx = _this$state.dx,
dy = _this$state.dy;
var point = (0, _event.localPoint)(event);
var point = (0, _event.localPoint)(event);
var nextState = _extends({}, this.state, {
var nextState = _objectSpread({}, this.state, {
isDragging: true,

@@ -71,3 +83,6 @@ dx: resetOnStart ? 0 : dx,

});
if (onDragStart) onDragStart(_extends({}, nextState, { event: event }));
if (onDragStart) onDragStart(_objectSpread({}, nextState, {
event: event
}));
this.setState(function () {

@@ -78,13 +93,13 @@ return nextState;

}, {
key: 'dragMove',
key: "dragMove",
value: function dragMove(event) {
var onDragMove = this.props.onDragMove;
var _state2 = this.state,
x = _state2.x,
y = _state2.y,
isDragging = _state2.isDragging;
var _this$state2 = this.state,
x = _this$state2.x,
y = _this$state2.y,
isDragging = _this$state2.isDragging;
if (!isDragging) return;
var point = (0, _event.localPoint)(event);
var nextState = _extends({}, this.state, {
var nextState = _objectSpread({}, this.state, {
isDragging: true,

@@ -94,3 +109,6 @@ dx: -(x - point.x),

});
if (onDragMove) onDragMove(_extends({}, nextState, { event: event }));
if (onDragMove) onDragMove(_objectSpread({}, nextState, {
event: event
}));
this.setState(function () {

@@ -101,11 +119,14 @@ return nextState;

}, {
key: 'dragEnd',
key: "dragEnd",
value: function dragEnd(event) {
var onDragEnd = this.props.onDragEnd;
var point = (0, _event.localPoint)(event);
var point = (0, _event.localPoint)(event);
var nextState = _extends({}, this.state, {
var nextState = _objectSpread({}, this.state, {
isDragging: false
});
if (onDragEnd) onDragEnd(_extends({}, nextState, { event: event }));
if (onDragEnd) onDragEnd(_objectSpread({}, nextState, {
event: event
}));
this.setState(function () {

@@ -116,37 +137,31 @@ return nextState;

}, {
key: 'render',
key: "render",
value: function render() {
var _state3 = this.state,
x = _state3.x,
y = _state3.y,
dx = _state3.dx,
dy = _state3.dy,
isDragging = _state3.isDragging;
var _props2 = this.props,
children = _props2.children,
width = _props2.width,
height = _props2.height,
captureDragArea = _props2.captureDragArea;
return _react2.default.createElement(
'g',
null,
isDragging && captureDragArea && _react2.default.createElement('rect', {
width: width,
height: height,
onMouseMove: this.dragMove,
onMouseUp: this.dragEnd,
fill: 'transparent'
}),
children({
x: x,
y: y,
dx: dx,
dy: dy,
isDragging: isDragging,
dragEnd: this.dragEnd,
dragMove: this.dragMove,
dragStart: this.dragStart
})
);
var _this$state3 = this.state,
x = _this$state3.x,
y = _this$state3.y,
dx = _this$state3.dx,
dy = _this$state3.dy,
isDragging = _this$state3.isDragging;
var _this$props2 = this.props,
children = _this$props2.children,
width = _this$props2.width,
height = _this$props2.height,
captureDragArea = _this$props2.captureDragArea;
return _react.default.createElement("g", null, isDragging && captureDragArea && _react.default.createElement("rect", {
width: width,
height: height,
onMouseMove: this.dragMove,
onMouseUp: this.dragEnd,
fill: "transparent"
}), children({
x: x,
y: y,
dx: dx,
dy: dy,
isDragging: isDragging,
dragEnd: this.dragEnd,
dragMove: this.dragMove,
dragStart: this.dragStart
}));
}

@@ -156,18 +171,15 @@ }]);

return Drag;
}(_react2.default.Component);
}(_react.default.Component);
exports.default = Drag;
Drag.propTypes = {
children: _propTypes2.default.func.isRequired,
width: _propTypes2.default.number.isRequired,
height: _propTypes2.default.number.isRequired,
captureDragArea: _propTypes2.default.bool,
resetOnStart: _propTypes2.default.bool,
onDragEnd: _propTypes2.default.func,
onDragMove: _propTypes2.default.func,
onDragStart: _propTypes2.default.func
children: _propTypes.default.func.isRequired,
width: _propTypes.default.number.isRequired,
height: _propTypes.default.number.isRequired,
captureDragArea: _propTypes.default.bool,
resetOnStart: _propTypes.default.bool,
onDragEnd: _propTypes.default.func,
onDragMove: _propTypes.default.func,
onDragStart: _propTypes.default.func
};
Drag.defaultProps = {

@@ -174,0 +186,0 @@ captureDragArea: true,

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,21 +6,19 @@ Object.defineProperty(exports, "__esModule", {

});
var _Drag = require('./Drag');
Object.defineProperty(exports, 'Drag', {
Object.defineProperty(exports, "Drag", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Drag).default;
return _Drag.default;
}
});
var _raise = require('./util/raise');
Object.defineProperty(exports, 'raise', {
Object.defineProperty(exports, "raise", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_raise).default;
return _raise.default;
}
});
var _Drag = _interopRequireDefault(require("./Drag"));
var _raise = _interopRequireDefault(require("./util/raise"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -7,2 +7,3 @@ "use strict";

exports.default = raise;
function raise(items, raiseIndex) {

@@ -9,0 +10,0 @@ var array = items.slice();

@@ -5,43 +5,61 @@ import { localPoint } from '@vx/event';

var classCallCheck = function (instance, Constructor) {
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
}
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
var _extends = Object.assign || function (target) {
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
};
}
var inherits = function (subClass, superClass) {
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
throw new TypeError("Super expression must either be null or a function");
}

@@ -52,3 +70,2 @@

value: subClass,
enumerable: false,
writable: true,

@@ -58,21 +75,48 @@ configurable: true

});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
if (superClass) _setPrototypeOf(subClass, superClass);
}
var possibleConstructorReturn = function (self, call) {
if (!self) {
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
return self;
}
var Drag = function (_React$Component) {
inherits(Drag, _React$Component);
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
var Drag =
/*#__PURE__*/
function (_React$Component) {
_inherits(Drag, _React$Component);
function Drag(props) {
classCallCheck(this, Drag);
var _this;
var _this = possibleConstructorReturn(this, (Drag.__proto__ || Object.getPrototypeOf(Drag)).call(this, props));
_classCallCheck(this, Drag);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Drag).call(this, props));
_this.state = {

@@ -85,20 +129,20 @@ x: undefined,

};
_this.dragEnd = _this.dragEnd.bind(_this);
_this.dragMove = _this.dragMove.bind(_this);
_this.dragStart = _this.dragStart.bind(_this);
_this.dragEnd = _this.dragEnd.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.dragMove = _this.dragMove.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.dragStart = _this.dragStart.bind(_assertThisInitialized(_assertThisInitialized(_this)));
return _this;
}
createClass(Drag, [{
key: 'dragStart',
_createClass(Drag, [{
key: "dragStart",
value: function dragStart(event) {
var _props = this.props,
onDragStart = _props.onDragStart,
resetOnStart = _props.resetOnStart;
var _state = this.state,
dx = _state.dx,
dy = _state.dy;
var _this$props = this.props,
onDragStart = _this$props.onDragStart,
resetOnStart = _this$props.resetOnStart;
var _this$state = this.state,
dx = _this$state.dx,
dy = _this$state.dy;
var point = localPoint(event);
var point = localPoint(event);
var nextState = _extends({}, this.state, {
var nextState = _objectSpread({}, this.state, {
isDragging: true,

@@ -110,3 +154,6 @@ dx: resetOnStart ? 0 : dx,

});
if (onDragStart) onDragStart(_extends({}, nextState, { event: event }));
if (onDragStart) onDragStart(_objectSpread({}, nextState, {
event: event
}));
this.setState(function () {

@@ -117,13 +164,13 @@ return nextState;

}, {
key: 'dragMove',
key: "dragMove",
value: function dragMove(event) {
var onDragMove = this.props.onDragMove;
var _state2 = this.state,
x = _state2.x,
y = _state2.y,
isDragging = _state2.isDragging;
var _this$state2 = this.state,
x = _this$state2.x,
y = _this$state2.y,
isDragging = _this$state2.isDragging;
if (!isDragging) return;
var point = localPoint(event);
var nextState = _extends({}, this.state, {
var nextState = _objectSpread({}, this.state, {
isDragging: true,

@@ -133,3 +180,6 @@ dx: -(x - point.x),

});
if (onDragMove) onDragMove(_extends({}, nextState, { event: event }));
if (onDragMove) onDragMove(_objectSpread({}, nextState, {
event: event
}));
this.setState(function () {

@@ -140,11 +190,14 @@ return nextState;

}, {
key: 'dragEnd',
key: "dragEnd",
value: function dragEnd(event) {
var onDragEnd = this.props.onDragEnd;
var point = localPoint(event);
var point = localPoint(event);
var nextState = _extends({}, this.state, {
var nextState = _objectSpread({}, this.state, {
isDragging: false
});
if (onDragEnd) onDragEnd(_extends({}, nextState, { event: event }));
if (onDragEnd) onDragEnd(_objectSpread({}, nextState, {
event: event
}));
this.setState(function () {

@@ -155,43 +208,36 @@ return nextState;

}, {
key: 'render',
key: "render",
value: function render() {
var _state3 = this.state,
x = _state3.x,
y = _state3.y,
dx = _state3.dx,
dy = _state3.dy,
isDragging = _state3.isDragging;
var _props2 = this.props,
children = _props2.children,
width = _props2.width,
height = _props2.height,
captureDragArea = _props2.captureDragArea;
return React.createElement(
'g',
null,
isDragging && captureDragArea && React.createElement('rect', {
width: width,
height: height,
onMouseMove: this.dragMove,
onMouseUp: this.dragEnd,
fill: 'transparent'
}),
children({
x: x,
y: y,
dx: dx,
dy: dy,
isDragging: isDragging,
dragEnd: this.dragEnd,
dragMove: this.dragMove,
dragStart: this.dragStart
})
);
var _this$state3 = this.state,
x = _this$state3.x,
y = _this$state3.y,
dx = _this$state3.dx,
dy = _this$state3.dy,
isDragging = _this$state3.isDragging;
var _this$props2 = this.props,
children = _this$props2.children,
width = _this$props2.width,
height = _this$props2.height,
captureDragArea = _this$props2.captureDragArea;
return React.createElement("g", null, isDragging && captureDragArea && React.createElement("rect", {
width: width,
height: height,
onMouseMove: this.dragMove,
onMouseUp: this.dragEnd,
fill: "transparent"
}), children({
x: x,
y: y,
dx: dx,
dy: dy,
isDragging: isDragging,
dragEnd: this.dragEnd,
dragMove: this.dragMove,
dragStart: this.dragStart
}));
}
}]);
return Drag;
}(React.Component);
Drag.propTypes = {

@@ -207,3 +253,2 @@ children: PropTypes.func.isRequired,

};
Drag.defaultProps = {

@@ -210,0 +255,0 @@ captureDragArea: true,

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@vx/event"),require("prop-types"),require("react")):"function"==typeof define&&define.amd?define(["exports","@vx/event","prop-types","react"],t):t(e.vx=e.vx||{},e.vx,e.PropTypes,e.React)}(this,function(e,c,t,f){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,f=f&&f.hasOwnProperty("default")?f.default:f;var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}(),d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},r=function(e){function r(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r);var t=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.state={x:void 0,y:void 0,dx:0,dy:0,isDragging:!1},t.dragEnd=t.dragEnd.bind(t),t.dragMove=t.dragMove.bind(t),t.dragStart=t.dragStart.bind(t),t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(r,f.Component),n(r,[{key:"dragStart",value:function(e){var t=this.props,r=t.onDragStart,n=t.resetOnStart,a=this.state,o=a.dx,i=a.dy,s=c.localPoint(e),u=d({},this.state,{isDragging:!0,dx:n?0:o,dy:n?0:i,x:n?s.x:-o+s.x,y:n?s.y:-i+s.y});r&&r(d({},u,{event:e})),this.setState(function(){return u})}},{key:"dragMove",value:function(e){var t=this.props.onDragMove,r=this.state,n=r.x,a=r.y;if(r.isDragging){var o=c.localPoint(e),i=d({},this.state,{isDragging:!0,dx:-(n-o.x),dy:-(a-o.y)});t&&t(d({},i,{event:e})),this.setState(function(){return i})}}},{key:"dragEnd",value:function(e){var t=this.props.onDragEnd,r=(c.localPoint(e),d({},this.state,{isDragging:!1}));t&&t(d({},r,{event:e})),this.setState(function(){return r})}},{key:"render",value:function(){var e=this.state,t=e.x,r=e.y,n=e.dx,a=e.dy,o=e.isDragging,i=this.props,s=i.children,u=i.width,c=i.height,d=i.captureDragArea;return f.createElement("g",null,o&&d&&f.createElement("rect",{width:u,height:c,onMouseMove:this.dragMove,onMouseUp:this.dragEnd,fill:"transparent"}),s({x:t,y:r,dx:n,dy:a,isDragging:o,dragEnd:this.dragEnd,dragMove:this.dragMove,dragStart:this.dragStart}))}}]),r}();r.propTypes={children:t.func.isRequired,width:t.number.isRequired,height:t.number.isRequired,captureDragArea:t.bool,resetOnStart:t.bool,onDragEnd:t.func,onDragMove:t.func,onDragStart:t.func},r.defaultProps={captureDragArea:!0,resetOnStart:!1},e.Drag=r,e.raise=function(e,t){var r=e.slice(),n=r.length-1,a=r.splice(t,1)[0];return r.splice(n,0,a),r},Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@vx/event"),require("prop-types"),require("react")):"function"==typeof define&&define.amd?define(["exports","@vx/event","prop-types","react"],t):t(e.vx=e.vx||{},e.vx,e.PropTypes,e.React)}(this,function(e,c,t,f){"use strict";function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function d(o){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{},t=Object.keys(a);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(a).filter(function(e){return Object.getOwnPropertyDescriptor(a,e).enumerable}))),t.forEach(function(e){var t,r,n;t=o,n=a[r=e],r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n})}return o}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}t=t&&t.hasOwnProperty("default")?t.default:t,f=f&&f.hasOwnProperty("default")?f.default:f;var r=function(e){function o(e){var t,r,n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),r=this,(t=!(n=i(o).call(this,e))||"object"!=typeof n&&"function"!=typeof n?s(r):n).state={x:void 0,y:void 0,dx:0,dy:0,isDragging:!1},t.dragEnd=t.dragEnd.bind(s(s(t))),t.dragMove=t.dragMove.bind(s(s(t))),t.dragStart=t.dragStart.bind(s(s(t))),t}var t,r,n;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}(o,f.Component),t=o,(r=[{key:"dragStart",value:function(e){var t=this.props,r=t.onDragStart,n=t.resetOnStart,o=this.state,a=o.dx,i=o.dy,u=c.localPoint(e),s=d({},this.state,{isDragging:!0,dx:n?0:a,dy:n?0:i,x:n?u.x:-a+u.x,y:n?u.y:-i+u.y});r&&r(d({},s,{event:e})),this.setState(function(){return s})}},{key:"dragMove",value:function(e){var t=this.props.onDragMove,r=this.state,n=r.x,o=r.y;if(r.isDragging){var a=c.localPoint(e),i=d({},this.state,{isDragging:!0,dx:-(n-a.x),dy:-(o-a.y)});t&&t(d({},i,{event:e})),this.setState(function(){return i})}}},{key:"dragEnd",value:function(e){var t=this.props.onDragEnd,r=(c.localPoint(e),d({},this.state,{isDragging:!1}));t&&t(d({},r,{event:e})),this.setState(function(){return r})}},{key:"render",value:function(){var e=this.state,t=e.x,r=e.y,n=e.dx,o=e.dy,a=e.isDragging,i=this.props,u=i.children,s=i.width,c=i.height,d=i.captureDragArea;return f.createElement("g",null,a&&d&&f.createElement("rect",{width:s,height:c,onMouseMove:this.dragMove,onMouseUp:this.dragEnd,fill:"transparent"}),u({x:t,y:r,dx:n,dy:o,isDragging:a,dragEnd:this.dragEnd,dragMove:this.dragMove,dragStart:this.dragStart}))}}])&&a(t.prototype,r),n&&a(t,n),o}();r.propTypes={children:t.func.isRequired,width:t.number.isRequired,height:t.number.isRequired,captureDragArea:t.bool,resetOnStart:t.bool,onDragEnd:t.func,onDragMove:t.func,onDragStart:t.func},r.defaultProps={captureDragArea:!0,resetOnStart:!1},e.Drag=r,e.raise=function(e,t){var r=e.slice(),n=r.length-1,o=r.splice(t,1)[0];return r.splice(n,0,o),r},Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "@vx/drag",
"version": "0.0.179",
"version": "0.0.182",
"description": "vx drag",

@@ -11,3 +11,3 @@ "sideEffects": false,

"build:dist": "rm -rf dist && mkdir dist && rollup -c",
"build:babel": "rm -rf build && mkdir build && babel src --out-dir build --ignore node_modules/ --presets stage-0,react,env",
"build:babel": "rm -rf build && mkdir build && babel src --out-dir build --ignore node_modules/ --presets @babel/preset-react,@babel/preset-env",
"prepublish": "npm run build",

@@ -41,9 +41,25 @@ "test": "jest"

"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-jest": "^21.2.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-external-helpers": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-do-expressions": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-bind": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.0.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.4.2",
"enzyme": "^3.1.0",

@@ -57,4 +73,4 @@ "enzyme-adapter-react-16": "^1.0.2",

"react-test-renderer": "^16.0.0",
"rollup": "^0.59.4",
"rollup-plugin-babel": "^3.0.4",
"rollup": "^0.67.4",
"rollup-plugin-babel": "^4.0.1",
"rollup-plugin-commonjs": "^9.1.3",

@@ -75,5 +91,5 @@ "rollup-plugin-node-resolve": "^3.3.0",

"dependencies": {
"@vx/event": "0.0.179",
"@vx/event": "0.0.182",
"prop-types": "^15.5.10"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc