react-draggable
Advanced tools
Comparing version 0.7.1 to 0.7.2
{ | ||
"name": "react-draggable", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"homepage": "https://github.com/mzabriskie/react-draggable", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -76,1 +76,5 @@ # Changelog | ||
the dragged position). Fixes #52. | ||
### 0.7.2 (May 8, 2015) | ||
- Added `moveOnStartChange` property. See README. |
@@ -390,2 +390,9 @@ 'use strict'; | ||
/** | ||
* `moveOnStartChange`, if true (default false) will move the element if the `start` | ||
* property changes. | ||
*/ | ||
moveOnStartChange: React.PropTypes.bool, | ||
/** | ||
* `zIndex` specifies the zIndex to use while dragging. | ||
@@ -478,2 +485,10 @@ * | ||
componentWillReceiveProps: function(newProps) { | ||
// React to changes in the 'start' param. | ||
if (newProps.moveOnStartChange && newProps.start && | ||
(newProps.start.x !== this.state.initialStart.x || newProps.start.y !== this.state.initialStart.y)) { | ||
this.setState(this.getInitialState(newProps)); | ||
} | ||
}, | ||
componentWillUnmount: function() { | ||
@@ -493,2 +508,3 @@ // Remove any leftover event handlers | ||
grid: null, | ||
moveOnStartChange: false, | ||
start: {x: 0, y: 0}, | ||
@@ -504,3 +520,5 @@ zIndex: NaN, | ||
getInitialState: function () { | ||
getInitialState: function (props) { | ||
// Handle call from CWRP | ||
props = props || this.props; | ||
return { | ||
@@ -514,3 +532,5 @@ // Whether or not we are currently dragging. | ||
// Current transform x and y. | ||
clientX: this.props.start.x, clientY: this.props.start.y | ||
clientX: props.start.x, clientY: props.start.y, | ||
initialStart: props.start | ||
}; | ||
@@ -517,0 +537,0 @@ }, |
{ | ||
"name": "react-draggable", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "React draggable component", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -87,2 +87,5 @@ # react-draggable [![Build Status](https://travis-ci.org/mzabriskie/react-draggable.svg?branch=master)](https://travis-ci.org/mzabriskie/react-draggable) | ||
// | ||
// `moveOnStartChange`, if true (default false), will move the element if there is a change in `start`. | ||
// We set this by default to `false` because it can cause unwanted effects if you are not aware of it. | ||
// | ||
// `zIndex` specifies the zIndex to use while dragging. | ||
@@ -99,2 +102,4 @@ // | ||
handle=".handle" | ||
start={{x: 0, y: 0}} | ||
moveOnStartChange={false} | ||
grid={[25, 25]} | ||
@@ -101,0 +106,0 @@ zIndex={100} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30418
617
140