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

react-draggable

Package Overview
Dependencies
Maintainers
2
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-draggable - npm Package Compare versions

Comparing version 2.0.0-beta1 to 2.0.0-beta2

2

bower.json
{
"name": "react-draggable",
"version": "2.0.0-beta1",
"version": "2.0.0-beta2",
"homepage": "https://github.com/mzabriskie/react-draggable",

@@ -5,0 +5,0 @@ "authors": [

# Changelog
### 2.0.0-beta2 (Apr 14, 2016)
- We're making a small deviation from React Core's controlled vs. uncontrolled scheme; for convenience,
`<Draggable>`s with a `position` property will still be draggable, but will revert to their old position
on drag stop. Attach an `onStop` or `onDrag` handler to synchronize state.
- A warning has been added informing users of this. If you make `<Draggable>` controlled but no callback
handlers, a warning will be printed.
### 2.0.0-beta1 (Apr 14, 2016)

@@ -4,0 +12,0 @@

@@ -217,7 +217,21 @@ (function webpackUniversalModuleDefinition(root, factory) {

_this.setState({
var newState = {
dragging: false,
slackX: 0,
slackY: 0
});
};
// If this is a controlled component, the result of this operation will be to
// revert back to the old position. We expect a handler on `onDragStop`, at the least.
var controlled = Boolean(_this.props.position);
if (controlled) {
var _this$props$position = _this.props.position;
var _x2 = _this$props$position.x;
var _y2 = _this$props$position.y;
newState.x = _x2;
newState.y = _y2;
}
_this.setState(newState);
}, _temp), _possibleConstructorReturn(_this, _ret);

@@ -227,2 +241,10 @@ }

_createClass(Draggable, [{
key: 'componentWillMount',
value: function componentWillMount() {
if (this.props.position && !(this.props.onDrag || this.props.onStop)) {
// eslint-disable-next-line
console.warn('A `position` was applied to this <Draggable>, without drag handlers. This will make this ' + 'component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the ' + '`position` of this element.');
}
}
}, {
key: 'componentDidMount',

@@ -254,14 +276,13 @@ value: function componentDidMount() {

// Add a CSS transform to move the element around. This allows us to move the element around
// without worrying about whether or not it is relatively or absolutely positioned.
// If the item you are dragging already has a transform set, wrap it in a <span> so <Draggable>
// has a clean slate.
// If this is controlled, we don't want to move it - unless it's dragging.
var controlled = Boolean(this.props.position);
var draggable = !controlled || this.state.dragging;
var position = this.props.position || this.props.defaultPosition;
var transformOpts = {
// Set left if horizontal drag is enabled
x: (0, _positionFns.canDragX)(this) && !controlled ? this.state.x : position.x,
x: (0, _positionFns.canDragX)(this) && draggable ? this.state.x : position.x,
// Set top if vertical drag is enabled
y: (0, _positionFns.canDragY)(this) && !controlled ? this.state.y : position.y
y: (0, _positionFns.canDragY)(this) && draggable ? this.state.y : position.y
};

@@ -273,2 +294,6 @@

} else {
// Add a CSS transform to move the element around. This allows us to move the element around
// without worrying about whether or not it is relatively or absolutely positioned.
// If the item you are dragging already has a transform set, wrap it in a <span> so <Draggable>
// has a clean slate.
style = (0, _domFns.createCSSTransform)(transformOpts);

@@ -275,0 +300,0 @@ }

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

!function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],factory):"object"==typeof exports?exports.ReactDraggable=factory(require("react"),require("react-dom")):root.ReactDraggable=factory(root.React,root.ReactDOM)}(this,function(__WEBPACK_EXTERNAL_MODULE_2__,__WEBPACK_EXTERNAL_MODULE_3__){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:!1};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.loaded=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.p="",__webpack_require__(0)}([function(module,exports,__webpack_require__){"use strict";module.exports=__webpack_require__(1)["default"],module.exports.DraggableCore=__webpack_require__(9)["default"]},function(module,exports,__webpack_require__){"use strict";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||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)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:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}Object.defineProperty(exports,"__esModule",{value:!0});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target},_slicedToArray=function(){function sliceIterator(arr,i){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}return function(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr))return sliceIterator(arr,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_react=__webpack_require__(2),_react2=_interopRequireDefault(_react),_reactDom=__webpack_require__(3),_reactDom2=_interopRequireDefault(_reactDom),_classnames=__webpack_require__(4),_classnames2=_interopRequireDefault(_classnames),_domFns=__webpack_require__(5),_positionFns=__webpack_require__(8),_shims=__webpack_require__(6),_DraggableCore=__webpack_require__(9),_DraggableCore2=_interopRequireDefault(_DraggableCore),_log=__webpack_require__(10),_log2=_interopRequireDefault(_log),Draggable=function(_React$Component){function Draggable(){var _Object$getPrototypeO,_temp,_this,_ret;_classCallCheck(this,Draggable);for(var _len=arguments.length,args=Array(_len),_key=0;_len>_key;_key++)args[_key]=arguments[_key];return _temp=_this=_possibleConstructorReturn(this,(_Object$getPrototypeO=Object.getPrototypeOf(Draggable)).call.apply(_Object$getPrototypeO,[this].concat(args))),_this.state={dragging:!1,dragged:!1,x:_this.props.position?_this.props.position.x:_this.props.defaultPosition.x,y:_this.props.position?_this.props.position.y:_this.props.defaultPosition.y,slackX:0,slackY:0,isElementSVG:!1},_this.onDragStart=function(e,coreData){(0,_log2["default"])("Draggable: onDragStart: %j",coreData);var shouldStart=_this.props.onStart(e,(0,_positionFns.createDraggableData)(_this,coreData));return shouldStart===!1?!1:void _this.setState({dragging:!0,dragged:!0})},_this.onDrag=function(e,coreData){if(!_this.state.dragging)return!1;(0,_log2["default"])("Draggable: onDrag: %j",coreData);var uiData=(0,_positionFns.createDraggableData)(_this,coreData),newState={x:uiData.x,y:uiData.y};if(_this.props.bounds){var _x=newState.x,_y=newState.y;newState.x+=_this.state.slackX,newState.y+=_this.state.slackY;var _getBoundPosition=(0,_positionFns.getBoundPosition)(_this,newState.x,newState.y),_getBoundPosition2=_slicedToArray(_getBoundPosition,2);newState.x=_getBoundPosition2[0],newState.y=_getBoundPosition2[1],newState.slackX=_this.state.slackX+(_x-newState.x),newState.slackY=_this.state.slackY+(_y-newState.y),uiData.x=_x,uiData.y=_y,uiData.deltaX=newState.x-_this.state.x,uiData.deltaY=newState.y-_this.state.y}var shouldUpdate=_this.props.onDrag(e,uiData);return shouldUpdate===!1?!1:void _this.setState(newState)},_this.onDragStop=function(e,coreData){if(!_this.state.dragging)return!1;var shouldStop=_this.props.onStop(e,(0,_positionFns.createDraggableData)(_this,coreData));return shouldStop===!1?!1:((0,_log2["default"])("Draggable: onDragStop: %j",coreData),void _this.setState({dragging:!1,slackX:0,slackY:0}))},_ret=_temp,_possibleConstructorReturn(_this,_ret)}return _inherits(Draggable,_React$Component),_createClass(Draggable,[{key:"componentDidMount",value:function(){_reactDom2["default"].findDOMNode(this)instanceof SVGElement&&this.setState({isElementSVG:!0})}},{key:"componentWillReceiveProps",value:function(nextProps){!nextProps.position||this.props.position&&nextProps.position.x===this.props.position.x&&nextProps.position.y===this.props.position.y||this.setState({x:nextProps.position.x,y:nextProps.position.y})}},{key:"componentWillUnmount",value:function(){this.setState({dragging:!1})}},{key:"render",value:function(){var style={},svgTransform=null,controlled=Boolean(this.props.position),position=this.props.position||this.props.defaultPosition,transformOpts={x:(0,_positionFns.canDragX)(this)&&!controlled?this.state.x:position.x,y:(0,_positionFns.canDragY)(this)&&!controlled?this.state.y:position.y};this.state.isElementSVG?svgTransform=(0,_domFns.createSVGTransform)(transformOpts):style=(0,_domFns.createCSSTransform)(transformOpts);var className=(0,_classnames2["default"])(this.props.children.props.className||"","react-draggable",{"react-draggable-dragging":this.state.dragging,"react-draggable-dragged":this.state.dragged});return _react2["default"].createElement(_DraggableCore2["default"],_extends({},this.props,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),_react2["default"].cloneElement(_react2["default"].Children.only(this.props.children),{className:className,style:_extends({},this.props.children.props.style,style),transform:svgTransform}))}}]),Draggable}(_react2["default"].Component);Draggable.displayName="Draggable",Draggable.propTypes=_extends({},_DraggableCore2["default"].propTypes,{axis:_react.PropTypes.oneOf(["both","x","y","none"]),bounds:_react.PropTypes.oneOfType([_react.PropTypes.shape({left:_react.PropTypes.number,right:_react.PropTypes.number,top:_react.PropTypes.number,bottom:_react.PropTypes.number}),_react.PropTypes.string,_react.PropTypes.oneOf([!1])]),defaultPosition:_react.PropTypes.shape({x:_react.PropTypes.number,y:_react.PropTypes.number}),position:_react.PropTypes.shape({x:_react.PropTypes.number,y:_react.PropTypes.number}),className:_shims.dontSetMe,style:_shims.dontSetMe,transform:_shims.dontSetMe}),Draggable.defaultProps=_extends({},_DraggableCore2["default"].defaultProps,{axis:"both",bounds:!1,defaultPosition:{x:0,y:0},position:null}),exports["default"]=Draggable},function(module,exports){module.exports=__WEBPACK_EXTERNAL_MODULE_2__},function(module,exports){module.exports=__WEBPACK_EXTERNAL_MODULE_3__},function(module,exports,__webpack_require__){var __WEBPACK_AMD_DEFINE_ARRAY__,__WEBPACK_AMD_DEFINE_RESULT__;!function(){"use strict";function classNames(){for(var classes=[],i=0;i<arguments.length;i++){var arg=arguments[i];if(arg){var argType=typeof arg;if("string"===argType||"number"===argType)classes.push(arg);else if(Array.isArray(arg))classes.push(classNames.apply(null,arg));else if("object"===argType)for(var key in arg)hasOwn.call(arg,key)&&arg[key]&&classes.push(key)}}return classes.join(" ")}var hasOwn={}.hasOwnProperty;"undefined"!=typeof module&&module.exports?module.exports=classNames:(__WEBPACK_AMD_DEFINE_ARRAY__=[],__WEBPACK_AMD_DEFINE_RESULT__=function(){return classNames}.apply(exports,__WEBPACK_AMD_DEFINE_ARRAY__),!(void 0!==__WEBPACK_AMD_DEFINE_RESULT__&&(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)))}()},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function matchesSelector(el,selector){return matchesSelectorFunc||(matchesSelectorFunc=(0,_shims.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(method){return(0,_shims.isFunction)(el[method])})),el[matchesSelectorFunc].call(el,selector)}function addEvent(el,event,handler){el&&(el.attachEvent?el.attachEvent("on"+event,handler):el.addEventListener?el.addEventListener(event,handler,!0):el["on"+event]=handler)}function removeEvent(el,event,handler){el&&(el.detachEvent?el.detachEvent("on"+event,handler):el.removeEventListener?el.removeEventListener(event,handler,!0):el["on"+event]=null)}function outerHeight(node){var height=node.clientHeight,computedStyle=window.getComputedStyle(node);return height+=(0,_shims["int"])(computedStyle.borderTopWidth),height+=(0,_shims["int"])(computedStyle.borderBottomWidth)}function outerWidth(node){var width=node.clientWidth,computedStyle=window.getComputedStyle(node);return width+=(0,_shims["int"])(computedStyle.borderLeftWidth),width+=(0,_shims["int"])(computedStyle.borderRightWidth)}function innerHeight(node){var height=node.clientHeight,computedStyle=window.getComputedStyle(node);return height-=(0,_shims["int"])(computedStyle.paddingTop),height-=(0,_shims["int"])(computedStyle.paddingBottom)}function innerWidth(node){var width=node.clientWidth,computedStyle=window.getComputedStyle(node);return width-=(0,_shims["int"])(computedStyle.paddingLeft),width-=(0,_shims["int"])(computedStyle.paddingRight)}function offsetXYFromParentOf(e,node){var evt=e.targetTouches?e.targetTouches[0]:e,offsetParent=node.offsetParent||document.body,offsetParentRect=node.offsetParent===document.body?{left:0,top:0}:offsetParent.getBoundingClientRect(),x=evt.clientX+offsetParent.scrollLeft-offsetParentRect.left,y=evt.clientY+offsetParent.scrollTop-offsetParentRect.top;return{x:x,y:y}}function createCSSTransform(_ref){var x=_ref.x,y=_ref.y;return _defineProperty({},(0,_getPrefix.browserPrefixToKey)("transform",_getPrefix2["default"]),"translate("+x+"px,"+y+"px)")}function createSVGTransform(_ref3){var x=_ref3.x,y=_ref3.y;return"translate("+x+","+y+")"}function addUserSelectStyles(){var style=document.body.getAttribute("style")||"";document.body.setAttribute("style",style+userSelectStyle)}function removeUserSelectStyles(){var style=document.body.getAttribute("style")||"";document.body.setAttribute("style",style.replace(userSelectStyle,""))}function styleHacks(){var childStyle=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return _extends({touchAction:"none"},childStyle)}Object.defineProperty(exports,"__esModule",{value:!0});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target};exports.matchesSelector=matchesSelector,exports.addEvent=addEvent,exports.removeEvent=removeEvent,exports.outerHeight=outerHeight,exports.outerWidth=outerWidth,exports.innerHeight=innerHeight,exports.innerWidth=innerWidth,exports.offsetXYFromParentOf=offsetXYFromParentOf,exports.createCSSTransform=createCSSTransform,exports.createSVGTransform=createSVGTransform,exports.addUserSelectStyles=addUserSelectStyles,exports.removeUserSelectStyles=removeUserSelectStyles,exports.styleHacks=styleHacks;var _shims=__webpack_require__(6),_getPrefix=__webpack_require__(7),_getPrefix2=_interopRequireDefault(_getPrefix),matchesSelectorFunc="",userSelectPrefix=(0,_getPrefix.getPrefix)("user-select"),userSelect=(0,_getPrefix.browserPrefixToStyle)("user-select",userSelectPrefix),userSelectStyle=";"+userSelect+": none;"},function(module,exports){"use strict";function findInArray(array,callback){for(var i=0,length=array.length;length>i;i++)if(callback.apply(callback,[array[i],i,array]))return array[i]}function isFunction(func){return"function"==typeof func||"[object Function]"===Object.prototype.toString.call(func)}function isNum(num){return"number"==typeof num&&!isNaN(num)}function int(a){return parseInt(a,10)}function dontSetMe(props,propName,componentName){return props[propName]?new Error("Invalid prop "+propName+" passed to "+componentName+" - do not set this, set it on the child."):void 0}Object.defineProperty(exports,"__esModule",{value:!0}),exports.findInArray=findInArray,exports.isFunction=isFunction,exports.isNum=isNum,exports["int"]=int,exports.dontSetMe=dontSetMe},function(module,exports){"use strict";function getPrefix(){var prop=arguments.length<=0||void 0===arguments[0]?"transform":arguments[0];if("undefined"==typeof window||"undefined"==typeof window.document)return"";var style=window.document.documentElement.style;if(prop in style)return"";for(var i=0;i<prefixes.length;i++)if(browserPrefixToKey(prop,prefixes[i])in style)return prefixes[i];return""}function browserPrefixToKey(prop,prefix){return prefix?""+prefix+kebabToTitleCase(prop):prop}function browserPrefixToStyle(prop,prefix){return prefix?"-"+prefix.toLowerCase()+"-"+prop:prop}function kebabToTitleCase(str){for(var out="",shouldCapitalize=!0,i=0;i<str.length;i++)shouldCapitalize?(out+=str[i].toUpperCase(),shouldCapitalize=!1):"-"===str[i]?shouldCapitalize=!0:out+=str[i];return out}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPrefix=getPrefix,exports.browserPrefixToKey=browserPrefixToKey,exports.browserPrefixToStyle=browserPrefixToStyle;var prefixes=["Moz","Webkit","O","ms"];exports["default"]=getPrefix()},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function getBoundPosition(draggable,x,y){if(!draggable.props.bounds)return[x,y];var bounds=draggable.props.bounds;bounds="string"==typeof bounds?bounds:cloneBounds(bounds);var node=_reactDom2["default"].findDOMNode(draggable);if("string"==typeof bounds){var boundNode=void 0;if("parent"===bounds)boundNode=node.parentNode;else if(boundNode=document.querySelector(bounds),!boundNode)throw new Error('Bounds selector "'+bounds+'" could not find an element.');var nodeStyle=window.getComputedStyle(node),boundNodeStyle=window.getComputedStyle(boundNode);bounds={left:-node.offsetLeft+(0,_shims["int"])(boundNodeStyle.paddingLeft)+(0,_shims["int"])(nodeStyle.borderLeftWidth)+(0,_shims["int"])(nodeStyle.marginLeft),top:-node.offsetTop+(0,_shims["int"])(boundNodeStyle.paddingTop)+(0,_shims["int"])(nodeStyle.borderTopWidth)+(0,_shims["int"])(nodeStyle.marginTop),right:(0,_domFns.innerWidth)(boundNode)-(0,_domFns.outerWidth)(node)-node.offsetLeft,bottom:(0,_domFns.innerHeight)(boundNode)-(0,_domFns.outerHeight)(node)-node.offsetTop}}return(0,_shims.isNum)(bounds.right)&&(x=Math.min(x,bounds.right)),(0,_shims.isNum)(bounds.bottom)&&(y=Math.min(y,bounds.bottom)),(0,_shims.isNum)(bounds.left)&&(x=Math.max(x,bounds.left)),(0,_shims.isNum)(bounds.top)&&(y=Math.max(y,bounds.top)),[x,y]}function snapToGrid(grid,pendingX,pendingY){var x=Math.round(pendingX/grid[0])*grid[0],y=Math.round(pendingY/grid[1])*grid[1];return[x,y]}function canDragX(draggable){return"both"===draggable.props.axis||"x"===draggable.props.axis}function canDragY(draggable){return"both"===draggable.props.axis||"y"===draggable.props.axis}function getControlPosition(e,draggableCore){return(0,_domFns.offsetXYFromParentOf)(e,_reactDom2["default"].findDOMNode(draggableCore))}function createCoreData(draggable,x,y){var state=draggable._pendingState||draggable.state,isStart=!(0,_shims.isNum)(state.lastX);return isStart?{node:_reactDom2["default"].findDOMNode(this),deltaX:0,deltaY:0,lastX:x,lastY:y,x:x,y:y}:{node:_reactDom2["default"].findDOMNode(this),deltaX:x-state.lastX,deltaY:y-state.lastY,lastX:state.lastX,lastY:state.lastY,x:x,y:y}}function createDraggableData(draggable,coreData){return{node:coreData.node,x:draggable.state.x+coreData.deltaX,y:draggable.state.y+coreData.deltaY,deltaX:coreData.deltaX,deltaY:coreData.deltaY,lastX:draggable.state.x,lastY:draggable.state.y}}function cloneBounds(bounds){return{left:bounds.left,top:bounds.top,right:bounds.right,bottom:bounds.bottom}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getBoundPosition=getBoundPosition,exports.snapToGrid=snapToGrid,exports.canDragX=canDragX,exports.canDragY=canDragY,exports.getControlPosition=getControlPosition,exports.createCoreData=createCoreData,exports.createDraggableData=createDraggableData;var _shims=__webpack_require__(6),_reactDom=__webpack_require__(3),_reactDom2=_interopRequireDefault(_reactDom),_domFns=__webpack_require__(5)},function(module,exports,__webpack_require__){"use strict";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||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)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:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}Object.defineProperty(exports,"__esModule",{value:!0});var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}return function(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr))return sliceIterator(arr,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_react=__webpack_require__(2),_react2=_interopRequireDefault(_react),_domFns=__webpack_require__(5),_positionFns=__webpack_require__(8),_shims=__webpack_require__(6),_log=__webpack_require__(10),_log2=_interopRequireDefault(_log),eventsFor={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}},dragEventFor=eventsFor.mouse,DraggableCore=function(_React$Component){function DraggableCore(){var _Object$getPrototypeO,_temp,_this,_ret;_classCallCheck(this,DraggableCore);for(var _len=arguments.length,args=Array(_len),_key=0;_len>_key;_key++)args[_key]=arguments[_key];return _temp=_this=_possibleConstructorReturn(this,(_Object$getPrototypeO=Object.getPrototypeOf(DraggableCore)).call.apply(_Object$getPrototypeO,[this].concat(args))),_this.state={dragging:!1,lastX:NaN,lastY:NaN,touchIdentifier:NaN},_this.handleDragStart=function(e){if(_this.props.onMouseDown(e),!_this.props.allowAnyClick&&"number"==typeof e.button&&0!==e.button)return!1;if(!(_this.props.disabled||!(e.target instanceof Node)||_this.props.handle&&!(0,_domFns.matchesSelector)(e.target,_this.props.handle)||_this.props.cancel&&(0,_domFns.matchesSelector)(e.target,_this.props.cancel))){e.targetTouches&&_this.setState({touchIdentifier:e.targetTouches[0].identifier}),_this.props.enableUserSelectHack&&(0,_domFns.addUserSelectStyles)();var _getControlPosition=(0,_positionFns.getControlPosition)(e,_this),x=_getControlPosition.x,y=_getControlPosition.y,coreEvent=(0,_positionFns.createCoreData)(_this,x,y);(0,_log2["default"])("DraggableCore: handleDragStart: %j",coreEvent),(0,_log2["default"])("calling",_this.props.onStart);var shouldUpdate=_this.props.onStart(e,coreEvent);shouldUpdate!==!1&&(_this.setState({dragging:!0,lastX:x,lastY:y}),(0,_domFns.addEvent)(document,dragEventFor.move,_this.handleDrag),(0,_domFns.addEvent)(document,dragEventFor.stop,_this.handleDragStop))}},_this.handleDrag=function(e){if(!e.targetTouches||e.targetTouches[0].identifier===_this.state.touchIdentifier){var _getControlPosition2=(0,_positionFns.getControlPosition)(e,_this),x=_getControlPosition2.x,y=_getControlPosition2.y;if(Array.isArray(_this.props.grid)){var deltaX=x-_this.state.lastX,deltaY=y-_this.state.lastY,_snapToGrid=(0,_positionFns.snapToGrid)(_this.props.grid,deltaX,deltaY),_snapToGrid2=_slicedToArray(_snapToGrid,2);if(deltaX=_snapToGrid2[0],deltaY=_snapToGrid2[1],!deltaX&&!deltaY)return;x=_this.state.lastX+deltaX,y=_this.state.lastY+deltaY}var coreEvent=(0,_positionFns.createCoreData)(_this,x,y);(0,_log2["default"])("DraggableCore: handleDrag: %j",coreEvent);var shouldUpdate=_this.props.onDrag(e,coreEvent);return shouldUpdate===!1?void _this.handleDragStop(new MouseEvent):void _this.setState({lastX:x,lastY:y})}},_this.handleDragStop=function(e){if(_this.state.dragging&&(!e.changedTouches||e.changedTouches[0].identifier===_this.state.touchIdentifier)){_this.props.enableUserSelectHack&&(0,_domFns.removeUserSelectStyles)();var _getControlPosition3=(0,_positionFns.getControlPosition)(e,_this),x=_getControlPosition3.x,y=_getControlPosition3.y,coreEvent=(0,_positionFns.createCoreData)(_this,x,y);(0,_log2["default"])("DraggableCore: handleDragStop: %j",coreEvent),_this.setState({dragging:!1,lastX:NaN,lastY:NaN}),_this.props.onStop(e,coreEvent),(0,_log2["default"])("DraggableCore: Removing handlers"),(0,_domFns.removeEvent)(document,dragEventFor.move,_this.handleDrag),(0,_domFns.removeEvent)(document,dragEventFor.stop,_this.handleDragStop)}},_this.onMouseDown=function(e){return dragEventFor=eventsFor.mouse,_this.handleDragStart(e)},_this.onMouseUp=function(e){return dragEventFor=eventsFor.mouse,_this.handleDragStop(e)},_this.onTouchStart=function(e){return dragEventFor=eventsFor.touch,_this.handleDragStart(e)},_this.onTouchEnd=function(e){return dragEventFor=eventsFor.touch,_this.handleDragStop(e)},_ret=_temp,_possibleConstructorReturn(_this,_ret)}return _inherits(DraggableCore,_React$Component),_createClass(DraggableCore,[{key:"componentWillUnmount",value:function(){(0,_domFns.removeEvent)(document,eventsFor.mouse.move,this.handleDrag),(0,_domFns.removeEvent)(document,eventsFor.touch.move,this.handleDrag),(0,_domFns.removeEvent)(document,eventsFor.mouse.stop,this.handleDragStop),(0,_domFns.removeEvent)(document,eventsFor.touch.stop,this.handleDragStop),this.props.enableUserSelectHack&&(0,_domFns.removeUserSelectStyles)()}},{key:"render",value:function(){return _react2["default"].cloneElement(_react2["default"].Children.only(this.props.children),{style:(0,_domFns.styleHacks)(this.props.children.props.style),onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}}]),DraggableCore}(_react2["default"].Component);DraggableCore.displayName="DraggableCore",DraggableCore.propTypes={allowAnyClick:_react.PropTypes.bool,disabled:_react.PropTypes.bool,enableUserSelectHack:_react.PropTypes.bool,grid:_react.PropTypes.arrayOf(_react.PropTypes.number),handle:_react.PropTypes.string,cancel:_react.PropTypes.string,onStart:_react.PropTypes.func,onDrag:_react.PropTypes.func,onStop:_react.PropTypes.func,onMouseDown:_react.PropTypes.func,className:_shims.dontSetMe,style:_shims.dontSetMe,transform:_shims.dontSetMe},DraggableCore.defaultProps={allowAnyClick:!1,cancel:null,disabled:!1,enableUserSelectHack:!0,handle:null,grid:null,transform:null,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){}},exports["default"]=DraggableCore},function(module,exports,__webpack_require__){"use strict";function log(){}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=log}])});
!function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],factory):"object"==typeof exports?exports.ReactDraggable=factory(require("react"),require("react-dom")):root.ReactDraggable=factory(root.React,root.ReactDOM)}(this,function(__WEBPACK_EXTERNAL_MODULE_2__,__WEBPACK_EXTERNAL_MODULE_3__){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:!1};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.loaded=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.p="",__webpack_require__(0)}([function(module,exports,__webpack_require__){"use strict";module.exports=__webpack_require__(1)["default"],module.exports.DraggableCore=__webpack_require__(9)["default"]},function(module,exports,__webpack_require__){"use strict";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||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)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:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}Object.defineProperty(exports,"__esModule",{value:!0});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target},_slicedToArray=function(){function sliceIterator(arr,i){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}return function(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr))return sliceIterator(arr,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_react=__webpack_require__(2),_react2=_interopRequireDefault(_react),_reactDom=__webpack_require__(3),_reactDom2=_interopRequireDefault(_reactDom),_classnames=__webpack_require__(4),_classnames2=_interopRequireDefault(_classnames),_domFns=__webpack_require__(5),_positionFns=__webpack_require__(8),_shims=__webpack_require__(6),_DraggableCore=__webpack_require__(9),_DraggableCore2=_interopRequireDefault(_DraggableCore),_log=__webpack_require__(10),_log2=_interopRequireDefault(_log),Draggable=function(_React$Component){function Draggable(){var _Object$getPrototypeO,_temp,_this,_ret;_classCallCheck(this,Draggable);for(var _len=arguments.length,args=Array(_len),_key=0;_len>_key;_key++)args[_key]=arguments[_key];return _temp=_this=_possibleConstructorReturn(this,(_Object$getPrototypeO=Object.getPrototypeOf(Draggable)).call.apply(_Object$getPrototypeO,[this].concat(args))),_this.state={dragging:!1,dragged:!1,x:_this.props.position?_this.props.position.x:_this.props.defaultPosition.x,y:_this.props.position?_this.props.position.y:_this.props.defaultPosition.y,slackX:0,slackY:0,isElementSVG:!1},_this.onDragStart=function(e,coreData){(0,_log2["default"])("Draggable: onDragStart: %j",coreData);var shouldStart=_this.props.onStart(e,(0,_positionFns.createDraggableData)(_this,coreData));return shouldStart===!1?!1:void _this.setState({dragging:!0,dragged:!0})},_this.onDrag=function(e,coreData){if(!_this.state.dragging)return!1;(0,_log2["default"])("Draggable: onDrag: %j",coreData);var uiData=(0,_positionFns.createDraggableData)(_this,coreData),newState={x:uiData.x,y:uiData.y};if(_this.props.bounds){var _x=newState.x,_y=newState.y;newState.x+=_this.state.slackX,newState.y+=_this.state.slackY;var _getBoundPosition=(0,_positionFns.getBoundPosition)(_this,newState.x,newState.y),_getBoundPosition2=_slicedToArray(_getBoundPosition,2);newState.x=_getBoundPosition2[0],newState.y=_getBoundPosition2[1],newState.slackX=_this.state.slackX+(_x-newState.x),newState.slackY=_this.state.slackY+(_y-newState.y),uiData.x=_x,uiData.y=_y,uiData.deltaX=newState.x-_this.state.x,uiData.deltaY=newState.y-_this.state.y}var shouldUpdate=_this.props.onDrag(e,uiData);return shouldUpdate===!1?!1:void _this.setState(newState)},_this.onDragStop=function(e,coreData){if(!_this.state.dragging)return!1;var shouldStop=_this.props.onStop(e,(0,_positionFns.createDraggableData)(_this,coreData));if(shouldStop===!1)return!1;(0,_log2["default"])("Draggable: onDragStop: %j",coreData);var newState={dragging:!1,slackX:0,slackY:0},controlled=Boolean(_this.props.position);if(controlled){var _this$props$position=_this.props.position,_x2=_this$props$position.x,_y2=_this$props$position.y;newState.x=_x2,newState.y=_y2}_this.setState(newState)},_ret=_temp,_possibleConstructorReturn(_this,_ret)}return _inherits(Draggable,_React$Component),_createClass(Draggable,[{key:"componentWillMount",value:function(){!this.props.position||this.props.onDrag||this.props.onStop||console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}},{key:"componentDidMount",value:function(){_reactDom2["default"].findDOMNode(this)instanceof SVGElement&&this.setState({isElementSVG:!0})}},{key:"componentWillReceiveProps",value:function(nextProps){!nextProps.position||this.props.position&&nextProps.position.x===this.props.position.x&&nextProps.position.y===this.props.position.y||this.setState({x:nextProps.position.x,y:nextProps.position.y})}},{key:"componentWillUnmount",value:function(){this.setState({dragging:!1})}},{key:"render",value:function(){var style={},svgTransform=null,controlled=Boolean(this.props.position),draggable=!controlled||this.state.dragging,position=this.props.position||this.props.defaultPosition,transformOpts={x:(0,_positionFns.canDragX)(this)&&draggable?this.state.x:position.x,y:(0,_positionFns.canDragY)(this)&&draggable?this.state.y:position.y};this.state.isElementSVG?svgTransform=(0,_domFns.createSVGTransform)(transformOpts):style=(0,_domFns.createCSSTransform)(transformOpts);var className=(0,_classnames2["default"])(this.props.children.props.className||"","react-draggable",{"react-draggable-dragging":this.state.dragging,"react-draggable-dragged":this.state.dragged});return _react2["default"].createElement(_DraggableCore2["default"],_extends({},this.props,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),_react2["default"].cloneElement(_react2["default"].Children.only(this.props.children),{className:className,style:_extends({},this.props.children.props.style,style),transform:svgTransform}))}}]),Draggable}(_react2["default"].Component);Draggable.displayName="Draggable",Draggable.propTypes=_extends({},_DraggableCore2["default"].propTypes,{axis:_react.PropTypes.oneOf(["both","x","y","none"]),bounds:_react.PropTypes.oneOfType([_react.PropTypes.shape({left:_react.PropTypes.number,right:_react.PropTypes.number,top:_react.PropTypes.number,bottom:_react.PropTypes.number}),_react.PropTypes.string,_react.PropTypes.oneOf([!1])]),defaultPosition:_react.PropTypes.shape({x:_react.PropTypes.number,y:_react.PropTypes.number}),position:_react.PropTypes.shape({x:_react.PropTypes.number,y:_react.PropTypes.number}),className:_shims.dontSetMe,style:_shims.dontSetMe,transform:_shims.dontSetMe}),Draggable.defaultProps=_extends({},_DraggableCore2["default"].defaultProps,{axis:"both",bounds:!1,defaultPosition:{x:0,y:0},position:null}),exports["default"]=Draggable},function(module,exports){module.exports=__WEBPACK_EXTERNAL_MODULE_2__},function(module,exports){module.exports=__WEBPACK_EXTERNAL_MODULE_3__},function(module,exports,__webpack_require__){var __WEBPACK_AMD_DEFINE_ARRAY__,__WEBPACK_AMD_DEFINE_RESULT__;!function(){"use strict";function classNames(){for(var classes=[],i=0;i<arguments.length;i++){var arg=arguments[i];if(arg){var argType=typeof arg;if("string"===argType||"number"===argType)classes.push(arg);else if(Array.isArray(arg))classes.push(classNames.apply(null,arg));else if("object"===argType)for(var key in arg)hasOwn.call(arg,key)&&arg[key]&&classes.push(key)}}return classes.join(" ")}var hasOwn={}.hasOwnProperty;"undefined"!=typeof module&&module.exports?module.exports=classNames:(__WEBPACK_AMD_DEFINE_ARRAY__=[],__WEBPACK_AMD_DEFINE_RESULT__=function(){return classNames}.apply(exports,__WEBPACK_AMD_DEFINE_ARRAY__),!(void 0!==__WEBPACK_AMD_DEFINE_RESULT__&&(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)))}()},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function matchesSelector(el,selector){return matchesSelectorFunc||(matchesSelectorFunc=(0,_shims.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(method){return(0,_shims.isFunction)(el[method])})),el[matchesSelectorFunc].call(el,selector)}function addEvent(el,event,handler){el&&(el.attachEvent?el.attachEvent("on"+event,handler):el.addEventListener?el.addEventListener(event,handler,!0):el["on"+event]=handler)}function removeEvent(el,event,handler){el&&(el.detachEvent?el.detachEvent("on"+event,handler):el.removeEventListener?el.removeEventListener(event,handler,!0):el["on"+event]=null)}function outerHeight(node){var height=node.clientHeight,computedStyle=window.getComputedStyle(node);return height+=(0,_shims["int"])(computedStyle.borderTopWidth),height+=(0,_shims["int"])(computedStyle.borderBottomWidth)}function outerWidth(node){var width=node.clientWidth,computedStyle=window.getComputedStyle(node);return width+=(0,_shims["int"])(computedStyle.borderLeftWidth),width+=(0,_shims["int"])(computedStyle.borderRightWidth)}function innerHeight(node){var height=node.clientHeight,computedStyle=window.getComputedStyle(node);return height-=(0,_shims["int"])(computedStyle.paddingTop),height-=(0,_shims["int"])(computedStyle.paddingBottom)}function innerWidth(node){var width=node.clientWidth,computedStyle=window.getComputedStyle(node);return width-=(0,_shims["int"])(computedStyle.paddingLeft),width-=(0,_shims["int"])(computedStyle.paddingRight)}function offsetXYFromParentOf(e,node){var evt=e.targetTouches?e.targetTouches[0]:e,offsetParent=node.offsetParent||document.body,offsetParentRect=node.offsetParent===document.body?{left:0,top:0}:offsetParent.getBoundingClientRect(),x=evt.clientX+offsetParent.scrollLeft-offsetParentRect.left,y=evt.clientY+offsetParent.scrollTop-offsetParentRect.top;return{x:x,y:y}}function createCSSTransform(_ref){var x=_ref.x,y=_ref.y;return _defineProperty({},(0,_getPrefix.browserPrefixToKey)("transform",_getPrefix2["default"]),"translate("+x+"px,"+y+"px)")}function createSVGTransform(_ref3){var x=_ref3.x,y=_ref3.y;return"translate("+x+","+y+")"}function addUserSelectStyles(){var style=document.body.getAttribute("style")||"";document.body.setAttribute("style",style+userSelectStyle)}function removeUserSelectStyles(){var style=document.body.getAttribute("style")||"";document.body.setAttribute("style",style.replace(userSelectStyle,""))}function styleHacks(){var childStyle=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return _extends({touchAction:"none"},childStyle)}Object.defineProperty(exports,"__esModule",{value:!0});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target};exports.matchesSelector=matchesSelector,exports.addEvent=addEvent,exports.removeEvent=removeEvent,exports.outerHeight=outerHeight,exports.outerWidth=outerWidth,exports.innerHeight=innerHeight,exports.innerWidth=innerWidth,exports.offsetXYFromParentOf=offsetXYFromParentOf,exports.createCSSTransform=createCSSTransform,exports.createSVGTransform=createSVGTransform,exports.addUserSelectStyles=addUserSelectStyles,exports.removeUserSelectStyles=removeUserSelectStyles,exports.styleHacks=styleHacks;var _shims=__webpack_require__(6),_getPrefix=__webpack_require__(7),_getPrefix2=_interopRequireDefault(_getPrefix),matchesSelectorFunc="",userSelectPrefix=(0,_getPrefix.getPrefix)("user-select"),userSelect=(0,_getPrefix.browserPrefixToStyle)("user-select",userSelectPrefix),userSelectStyle=";"+userSelect+": none;"},function(module,exports){"use strict";function findInArray(array,callback){for(var i=0,length=array.length;length>i;i++)if(callback.apply(callback,[array[i],i,array]))return array[i]}function isFunction(func){return"function"==typeof func||"[object Function]"===Object.prototype.toString.call(func)}function isNum(num){return"number"==typeof num&&!isNaN(num)}function int(a){return parseInt(a,10)}function dontSetMe(props,propName,componentName){return props[propName]?new Error("Invalid prop "+propName+" passed to "+componentName+" - do not set this, set it on the child."):void 0}Object.defineProperty(exports,"__esModule",{value:!0}),exports.findInArray=findInArray,exports.isFunction=isFunction,exports.isNum=isNum,exports["int"]=int,exports.dontSetMe=dontSetMe},function(module,exports){"use strict";function getPrefix(){var prop=arguments.length<=0||void 0===arguments[0]?"transform":arguments[0];if("undefined"==typeof window||"undefined"==typeof window.document)return"";var style=window.document.documentElement.style;if(prop in style)return"";for(var i=0;i<prefixes.length;i++)if(browserPrefixToKey(prop,prefixes[i])in style)return prefixes[i];return""}function browserPrefixToKey(prop,prefix){return prefix?""+prefix+kebabToTitleCase(prop):prop}function browserPrefixToStyle(prop,prefix){return prefix?"-"+prefix.toLowerCase()+"-"+prop:prop}function kebabToTitleCase(str){for(var out="",shouldCapitalize=!0,i=0;i<str.length;i++)shouldCapitalize?(out+=str[i].toUpperCase(),shouldCapitalize=!1):"-"===str[i]?shouldCapitalize=!0:out+=str[i];return out}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPrefix=getPrefix,exports.browserPrefixToKey=browserPrefixToKey,exports.browserPrefixToStyle=browserPrefixToStyle;var prefixes=["Moz","Webkit","O","ms"];exports["default"]=getPrefix()},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function getBoundPosition(draggable,x,y){if(!draggable.props.bounds)return[x,y];var bounds=draggable.props.bounds;bounds="string"==typeof bounds?bounds:cloneBounds(bounds);var node=_reactDom2["default"].findDOMNode(draggable);if("string"==typeof bounds){var boundNode=void 0;if("parent"===bounds)boundNode=node.parentNode;else if(boundNode=document.querySelector(bounds),!boundNode)throw new Error('Bounds selector "'+bounds+'" could not find an element.');var nodeStyle=window.getComputedStyle(node),boundNodeStyle=window.getComputedStyle(boundNode);bounds={left:-node.offsetLeft+(0,_shims["int"])(boundNodeStyle.paddingLeft)+(0,_shims["int"])(nodeStyle.borderLeftWidth)+(0,_shims["int"])(nodeStyle.marginLeft),top:-node.offsetTop+(0,_shims["int"])(boundNodeStyle.paddingTop)+(0,_shims["int"])(nodeStyle.borderTopWidth)+(0,_shims["int"])(nodeStyle.marginTop),right:(0,_domFns.innerWidth)(boundNode)-(0,_domFns.outerWidth)(node)-node.offsetLeft,bottom:(0,_domFns.innerHeight)(boundNode)-(0,_domFns.outerHeight)(node)-node.offsetTop}}return(0,_shims.isNum)(bounds.right)&&(x=Math.min(x,bounds.right)),(0,_shims.isNum)(bounds.bottom)&&(y=Math.min(y,bounds.bottom)),(0,_shims.isNum)(bounds.left)&&(x=Math.max(x,bounds.left)),(0,_shims.isNum)(bounds.top)&&(y=Math.max(y,bounds.top)),[x,y]}function snapToGrid(grid,pendingX,pendingY){var x=Math.round(pendingX/grid[0])*grid[0],y=Math.round(pendingY/grid[1])*grid[1];return[x,y]}function canDragX(draggable){return"both"===draggable.props.axis||"x"===draggable.props.axis}function canDragY(draggable){return"both"===draggable.props.axis||"y"===draggable.props.axis}function getControlPosition(e,draggableCore){return(0,_domFns.offsetXYFromParentOf)(e,_reactDom2["default"].findDOMNode(draggableCore))}function createCoreData(draggable,x,y){var state=draggable._pendingState||draggable.state,isStart=!(0,_shims.isNum)(state.lastX);return isStart?{node:_reactDom2["default"].findDOMNode(this),deltaX:0,deltaY:0,lastX:x,lastY:y,x:x,y:y}:{node:_reactDom2["default"].findDOMNode(this),deltaX:x-state.lastX,deltaY:y-state.lastY,lastX:state.lastX,lastY:state.lastY,x:x,y:y}}function createDraggableData(draggable,coreData){return{node:coreData.node,x:draggable.state.x+coreData.deltaX,y:draggable.state.y+coreData.deltaY,deltaX:coreData.deltaX,deltaY:coreData.deltaY,lastX:draggable.state.x,lastY:draggable.state.y}}function cloneBounds(bounds){return{left:bounds.left,top:bounds.top,right:bounds.right,bottom:bounds.bottom}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getBoundPosition=getBoundPosition,exports.snapToGrid=snapToGrid,exports.canDragX=canDragX,exports.canDragY=canDragY,exports.getControlPosition=getControlPosition,exports.createCoreData=createCoreData,exports.createDraggableData=createDraggableData;var _shims=__webpack_require__(6),_reactDom=__webpack_require__(3),_reactDom2=_interopRequireDefault(_reactDom),_domFns=__webpack_require__(5)},function(module,exports,__webpack_require__){"use strict";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||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)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:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}Object.defineProperty(exports,"__esModule",{value:!0});var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}return function(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr))return sliceIterator(arr,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_react=__webpack_require__(2),_react2=_interopRequireDefault(_react),_domFns=__webpack_require__(5),_positionFns=__webpack_require__(8),_shims=__webpack_require__(6),_log=__webpack_require__(10),_log2=_interopRequireDefault(_log),eventsFor={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}},dragEventFor=eventsFor.mouse,DraggableCore=function(_React$Component){function DraggableCore(){var _Object$getPrototypeO,_temp,_this,_ret;_classCallCheck(this,DraggableCore);for(var _len=arguments.length,args=Array(_len),_key=0;_len>_key;_key++)args[_key]=arguments[_key];return _temp=_this=_possibleConstructorReturn(this,(_Object$getPrototypeO=Object.getPrototypeOf(DraggableCore)).call.apply(_Object$getPrototypeO,[this].concat(args))),_this.state={dragging:!1,lastX:NaN,lastY:NaN,touchIdentifier:NaN},_this.handleDragStart=function(e){if(_this.props.onMouseDown(e),!_this.props.allowAnyClick&&"number"==typeof e.button&&0!==e.button)return!1;if(!(_this.props.disabled||!(e.target instanceof Node)||_this.props.handle&&!(0,_domFns.matchesSelector)(e.target,_this.props.handle)||_this.props.cancel&&(0,_domFns.matchesSelector)(e.target,_this.props.cancel))){e.targetTouches&&_this.setState({touchIdentifier:e.targetTouches[0].identifier}),_this.props.enableUserSelectHack&&(0,_domFns.addUserSelectStyles)();var _getControlPosition=(0,_positionFns.getControlPosition)(e,_this),x=_getControlPosition.x,y=_getControlPosition.y,coreEvent=(0,_positionFns.createCoreData)(_this,x,y);(0,_log2["default"])("DraggableCore: handleDragStart: %j",coreEvent),(0,_log2["default"])("calling",_this.props.onStart);var shouldUpdate=_this.props.onStart(e,coreEvent);shouldUpdate!==!1&&(_this.setState({dragging:!0,lastX:x,lastY:y}),(0,_domFns.addEvent)(document,dragEventFor.move,_this.handleDrag),(0,_domFns.addEvent)(document,dragEventFor.stop,_this.handleDragStop))}},_this.handleDrag=function(e){if(!e.targetTouches||e.targetTouches[0].identifier===_this.state.touchIdentifier){var _getControlPosition2=(0,_positionFns.getControlPosition)(e,_this),x=_getControlPosition2.x,y=_getControlPosition2.y;if(Array.isArray(_this.props.grid)){var deltaX=x-_this.state.lastX,deltaY=y-_this.state.lastY,_snapToGrid=(0,_positionFns.snapToGrid)(_this.props.grid,deltaX,deltaY),_snapToGrid2=_slicedToArray(_snapToGrid,2);if(deltaX=_snapToGrid2[0],deltaY=_snapToGrid2[1],!deltaX&&!deltaY)return;x=_this.state.lastX+deltaX,y=_this.state.lastY+deltaY}var coreEvent=(0,_positionFns.createCoreData)(_this,x,y);(0,_log2["default"])("DraggableCore: handleDrag: %j",coreEvent);var shouldUpdate=_this.props.onDrag(e,coreEvent);return shouldUpdate===!1?void _this.handleDragStop(new MouseEvent):void _this.setState({lastX:x,lastY:y})}},_this.handleDragStop=function(e){if(_this.state.dragging&&(!e.changedTouches||e.changedTouches[0].identifier===_this.state.touchIdentifier)){_this.props.enableUserSelectHack&&(0,_domFns.removeUserSelectStyles)();var _getControlPosition3=(0,_positionFns.getControlPosition)(e,_this),x=_getControlPosition3.x,y=_getControlPosition3.y,coreEvent=(0,_positionFns.createCoreData)(_this,x,y);(0,_log2["default"])("DraggableCore: handleDragStop: %j",coreEvent),_this.setState({dragging:!1,lastX:NaN,lastY:NaN}),_this.props.onStop(e,coreEvent),(0,_log2["default"])("DraggableCore: Removing handlers"),(0,_domFns.removeEvent)(document,dragEventFor.move,_this.handleDrag),(0,_domFns.removeEvent)(document,dragEventFor.stop,_this.handleDragStop)}},_this.onMouseDown=function(e){return dragEventFor=eventsFor.mouse,_this.handleDragStart(e)},_this.onMouseUp=function(e){return dragEventFor=eventsFor.mouse,_this.handleDragStop(e)},_this.onTouchStart=function(e){return dragEventFor=eventsFor.touch,_this.handleDragStart(e)},_this.onTouchEnd=function(e){return dragEventFor=eventsFor.touch,_this.handleDragStop(e)},_ret=_temp,_possibleConstructorReturn(_this,_ret)}return _inherits(DraggableCore,_React$Component),_createClass(DraggableCore,[{key:"componentWillUnmount",value:function(){(0,_domFns.removeEvent)(document,eventsFor.mouse.move,this.handleDrag),(0,_domFns.removeEvent)(document,eventsFor.touch.move,this.handleDrag),(0,_domFns.removeEvent)(document,eventsFor.mouse.stop,this.handleDragStop),(0,_domFns.removeEvent)(document,eventsFor.touch.stop,this.handleDragStop),this.props.enableUserSelectHack&&(0,_domFns.removeUserSelectStyles)()}},{key:"render",value:function(){return _react2["default"].cloneElement(_react2["default"].Children.only(this.props.children),{style:(0,_domFns.styleHacks)(this.props.children.props.style),onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}}]),DraggableCore}(_react2["default"].Component);DraggableCore.displayName="DraggableCore",DraggableCore.propTypes={allowAnyClick:_react.PropTypes.bool,disabled:_react.PropTypes.bool,enableUserSelectHack:_react.PropTypes.bool,grid:_react.PropTypes.arrayOf(_react.PropTypes.number),handle:_react.PropTypes.string,cancel:_react.PropTypes.string,onStart:_react.PropTypes.func,onDrag:_react.PropTypes.func,onStop:_react.PropTypes.func,onMouseDown:_react.PropTypes.func,className:_shims.dontSetMe,style:_shims.dontSetMe,transform:_shims.dontSetMe},DraggableCore.defaultProps={allowAnyClick:!1,cancel:null,disabled:!1,enableUserSelectHack:!0,handle:null,grid:null,transform:null,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){}},exports["default"]=DraggableCore},function(module,exports,__webpack_require__){"use strict";function log(){}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=log}])});
//# sourceMappingURL=dist/react-draggable.min.js
{
"name": "react-draggable",
"version": "2.0.0-beta1",
"version": "2.0.0-beta2",
"description": "React draggable component",

@@ -32,3 +32,3 @@ "main": "dist/react-draggable.js",

"babel-core": "^6.5.1",
"babel-eslint": "^4.1.8",
"babel-eslint": "^6.0.2",
"babel-loader": "^6.2.2",

@@ -38,15 +38,15 @@ "babel-preset-es2015": "^6.5.0",

"babel-preset-stage-1": "^6.5.0",
"eslint": "^1.7.3",
"eslint-plugin-react": "^3.6.3",
"eslint": "^2.7.0",
"eslint-plugin-react": "^4.3.0",
"karma": "^0.13.14",
"karma-chrome-launcher": "^0.2.1",
"karma-cli": "0.1.1",
"karma-cli": "0.1.2",
"karma-firefox-launcher": "^0.1.6",
"karma-jasmine": "^0.3.6",
"karma-phantomjs-launcher": "^0.2.1",
"karma-phantomjs-launcher": "^1.0.0",
"karma-phantomjs-shim": "^1.1.1",
"karma-webpack": "^1.7.0",
"lodash": "^3.10.1",
"lodash": "^4.11.1",
"open": "0.0.5",
"phantomjs": "^1.9.18",
"phantomjs-prebuilt": ">=1.9",
"pre-commit": "^1.1.2",

@@ -53,0 +53,0 @@ "react": "^15.0.0",

@@ -27,3 +27,4 @@ # React-Draggable [![Build Status](https://travis-ci.org/mzabriskie/react-draggable.svg?branch=master)](https://travis-ci.org/mzabriskie/react-draggable)

The default export is `<Draggable>`. At the `.DraggableCore` property is `<DraggableCore>`. Here's how to use it:
The default export is `<Draggable>`. At the `.DraggableCore` property is [`<DraggableCore>`](#draggablecore).
Here's how to use it:

@@ -41,3 +42,3 @@ ```js

## Draggable
## `<Draggable>`

@@ -59,11 +60,11 @@ A `<Draggable>` element wraps an existing element and extends it with new event handlers and styles.

For the `<Draggable/>` component to correctly attach itself to its child, the child element must provide support for the following props:
For the `<Draggable/>` component to correctly attach itself to its child, the child element must provide support
for the following props:
- `style` is used to give the transform css to the child.
- `className` is used to apply the proper classes to the object being dragged.
- `onMouseDown` is used along with onMouseUp to keep track of dragging state.
- `onMouseUp` is used along with onMouseDown to keep track of dragging state.
- `onTouchStart` is used along with onTouchEnd to keep track of dragging state.
- `onTouchEnd` is used along with onTouchStart to keep track of dragging state.
- `onMouseDown`, `onMouseUp`, `onTouchStart`, and `onTouchEnd` are used to keep track of dragging state.
React.DOM elements support the above six properties by default, so you may use those elements as children without any changes. If you wish to use a React component you created, you might find [this React page](https://facebook.github.io/react/docs/transferring-props.html) helpful.
React.DOM elements support the above six properties by default, so you may use those elements as children without
any changes. If you wish to use a React component you created, you might find
[this React page](https://facebook.github.io/react/docs/transferring-props.html) helpful.

@@ -195,11 +196,32 @@ Props:

## <DraggableCore>
## Controlled vs. Uncontrolled
For users that require more control, a `<DraggableCore>` element is available. This is useful for more programmatic
usage of the element. See [React-Resizable](https://github.com/STRML/react-resizable) and
[React-Grid-Layout](https://github.com/STRML/react-grid-layout) for some examples of this.
`<Draggable>` is a 'batteries-included' component that manages its own state. If you want to completely
control the lifecycle of the component, use `<DraggableCore>`.
For some users, they may want the nice state management that `<Draggable>` provides, but occasionally want
to programmatically reposition their components. `<Draggable>` allows this customization via a system that
is similar to how React handles form components.
If the prop `position: {x: number, y: number}` is defined, the `<Draggable>` will ignore its internal state and use
the provided position instead. Altneratively, you can seed the position using `defaultPosition`. Technically, since
`<Draggable>` works only on position deltas, you could also seed the initial position using CSS `top/left`.
We make one modification to the React philosophy here - we still allow dragging while a component is controlled.
We then expect you to use at least an `onDrag` or `onStop` handler to synchronize state.
To disable dragging while controlled, send the prop `disabled={true}` - at this point the `<Draggable>` will operate
like a completely static component.
## `<DraggableCore>`
For users that require absolute control, a `<DraggableCore>` element is available. This is useful as an abstraction
over touch and mouse events, but with full control. `<DraggableCore>` has no internal state.
See [React-Resizable](https://github.com/STRML/react-resizable) and
[React-Grid-Layout](https://github.com/STRML/react-grid-layout) for some usage examples.
`<DraggableCore>` is a useful building block for other libraries that simply want to abstract browser-specific
quirks and receive callbacks when a user attempts to move an element. It does not set styles or transforms
on itself.
on itself and thus must have callbacks attached to be useful.

@@ -229,17 +251,4 @@ ### DraggableCore API

Drag callbacks (`onDragStart`, `onDrag`, `onDragEnd`) are called with the following parameters:
Drag callbacks (`onStart`, `onDrag`, `onStop`) are called with the [same arguments as `<Draggable>`](#draggable-api).
```js
(
event: Event,
data: {
node: HTMLElement,
// lastX + deltaX === x
x: number, y: number,
deltaX: number, deltaY: number,
lastX: number, lastY: number
}
)
```
----

@@ -246,0 +255,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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