react-resizable 1.9.0 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.10.1 (Nov 25, 2019)
4
+
5
+ > Note: 1.10.0 was a mis-publish.
6
+
7
+ - Feat: Add `transformScale` prop [#115](https://github.com/STRML/react-resizable/pull/115)
8
+ - Bugfix: Resolve `getDerivedStateFromProps` dev warning [#117](https://github.com/STRML/react-resizable/pull/117)
9
+
3
10
  ### 1.9.0 (Oct 24, 2019)
4
11
 
5
12
  - Fix resize with north/south handles when `lockAspectRatio=true` [#106](https://github.com/STRML/react-resizable/pull/106)
@@ -128,7 +128,9 @@ function (_React$Component) {
128
128
  var node = _ref2.node,
129
129
  deltaX = _ref2.deltaX,
130
130
  deltaY = _ref2.deltaY;
131
- // Axis restrictions
131
+ deltaX /= _this2.props.transformScale;
132
+ deltaY /= _this2.props.transformScale; // Axis restrictions
133
+
132
134
  var canDragX = (_this2.props.axis === 'both' || _this2.props.axis === 'x') && ['n', 's'].indexOf(axis) === -1;
133
135
  var canDragY = (_this2.props.axis === 'both' || _this2.props.axis === 'y') && ['e', 'w'].indexOf(axis) === -1; // reverse delta if using top or left drag handles
134
136
 
@@ -219,7 +221,8 @@ function (_React$Component) {
219
221
  onResizeStop = _this$props.onResizeStop,
220
222
  onResizeStart = _this$props.onResizeStart,
221
223
  resizeHandles = _this$props.resizeHandles,
222
- p = _objectWithoutPropertiesLoose(_this$props, ["children", "draggableOpts", "width", "height", "handleSize", "lockAspectRatio", "axis", "minConstraints", "maxConstraints", "onResize", "onResizeStop", "onResizeStart", "resizeHandles"]);
224
+ transformScale = _this$props.transformScale,
225
+ p = _objectWithoutPropertiesLoose(_this$props, ["children", "draggableOpts", "width", "height", "handleSize", "lockAspectRatio", "axis", "minConstraints", "maxConstraints", "onResize", "onResizeStop", "onResizeStart", "resizeHandles", "transformScale"]);
223
226
 
224
227
  var className = p.className ? p.className + " react-resizable" : 'react-resizable'; // What we're doing here is getting the child of this element, and cloning it with this element's props.
225
228
  // We are then defining its children as:
@@ -271,6 +274,7 @@ _defineProperty(Resizable, "propTypes", {
271
274
  // 'se' - Southeast handle (bottom-right)
272
275
  // 'ne' - Northeast handle (top-center)
273
276
  resizeHandles: _propTypes.default.arrayOf(_propTypes.default.oneOf(['s', 'w', 'e', 'n', 'sw', 'nw', 'se', 'ne'])),
277
+ transformScale: _propTypes.default.number,
274
278
  // If true, will only allow width/height to move in lockstep
275
279
  lockAspectRatio: _propTypes.default.bool,
276
280
  // Restricts resizing to a particular axis (default: 'both')
@@ -296,5 +300,6 @@ _defineProperty(Resizable, "defaultProps", {
296
300
  axis: 'both',
297
301
  minConstraints: [20, 20],
298
302
  maxConstraints: [Infinity, Infinity],
299
- resizeHandles: ['se']
303
+ resizeHandles: ['se'],
304
+ transformScale: 1
300
305
  });
@@ -36,7 +36,8 @@ export type Props = {
36
36
  onResizeStart?: ?(e: SyntheticEvent<>, data: ResizeCallbackData) => any,
37
37
  onResize?: ?(e: SyntheticEvent<>, data: ResizeCallbackData) => any,
38
38
  draggableOpts?: ?Object,
39
- resizeHandles: ResizeHandle[]
39
+ resizeHandles: ResizeHandle[],
40
+ transformScale: number,
40
41
  };
41
42
 
42
43
  export default class Resizable extends React.Component<Props, State> {
@@ -73,6 +74,7 @@ export default class Resizable extends React.Component<Props, State> {
73
74
  // 'se' - Southeast handle (bottom-right)
74
75
  // 'ne' - Northeast handle (top-center)
75
76
  resizeHandles: PropTypes.arrayOf(PropTypes.oneOf(['s', 'w', 'e', 'n', 'sw', 'nw', 'se', 'ne'])),
77
+ transformScale: PropTypes.number,
76
78
 
77
79
  // If true, will only allow width/height to move in lockstep
78
80
  lockAspectRatio: PropTypes.bool,
@@ -103,7 +105,8 @@ export default class Resizable extends React.Component<Props, State> {
103
105
  axis: 'both',
104
106
  minConstraints: [20, 20],
105
107
  maxConstraints: [Infinity, Infinity],
106
- resizeHandles: ['se']
108
+ resizeHandles: ['se'],
109
+ transformScale: 1
107
110
  };
108
111
 
109
112
  state: State = {
@@ -172,6 +175,8 @@ export default class Resizable extends React.Component<Props, State> {
172
175
  */
173
176
  resizeHandler(handlerName: string, axis: ResizeHandle): Function {
174
177
  return (e: SyntheticEvent<> | MouseEvent, {node, deltaX, deltaY}: DragCallbackData) => {
178
+ deltaX /= this.props.transformScale;
179
+ deltaY /= this.props.transformScale;
175
180
 
176
181
  // Axis restrictions
177
182
  const canDragX = (this.props.axis === 'both' || this.props.axis === 'x') && ['n', 's'].indexOf(axis) === -1;
@@ -232,7 +237,7 @@ export default class Resizable extends React.Component<Props, State> {
232
237
  // eslint-disable-next-line no-unused-vars
233
238
  const {children, draggableOpts, width, height, handleSize,
234
239
  lockAspectRatio, axis, minConstraints, maxConstraints, onResize,
235
- onResizeStop, onResizeStart, resizeHandles, ...p} = this.props;
240
+ onResizeStop, onResizeStart, resizeHandles, transformScale, ...p} = this.props;
236
241
 
237
242
  const className = p.className ?
238
243
  `${p.className} react-resizable`:
@@ -72,6 +72,8 @@ function (_React$Component) {
72
72
  propsHeight: props.height
73
73
  };
74
74
  }
75
+
76
+ return null;
75
77
  };
76
78
 
77
79
  var _proto = ResizableBox.prototype;
@@ -38,6 +38,7 @@ export default class ResizableBox extends React.Component<ResizableProps, State>
38
38
  propsHeight: props.height,
39
39
  };
40
40
  }
41
+ return null;
41
42
  }
42
43
 
43
44
  onResize = (e: SyntheticEvent<>, data: ResizeCallbackData) => {
package/index.html ADDED
@@ -0,0 +1,15 @@
1
+ <html>
2
+ <head>
3
+ <style>
4
+ body {
5
+ background: darkblue;
6
+ color: white;
7
+ font-size: 32px;
8
+ }
9
+ </style>
10
+ </head>
11
+ <body>
12
+ Hello! This is a website wow
13
+ <div style="background-color: black; width: 200px; height: 200px">BOX</div>
14
+ </body>
15
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-resizable",
3
- "version": "1.9.0",
3
+ "version": "1.10.1",
4
4
  "description": "A component that is resizable with handles.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,23 +0,0 @@
1
- ### Thanks for opening an issue!
2
-
3
- Please select the type of issue you're reporting. For questions.
4
-
5
- - [ ] Bug
6
- - [ ] Feature Request
7
- - [ ] Question
8
-
9
- ### Problem Report
10
-
11
- > Please describe the problem here.
12
-
13
- #### System Info
14
-
15
- Node Version:
16
- Browser:
17
- OS:
18
-
19
- #### Reproduction
20
-
21
- If this is a bug report, please provide a reproduction of the issue by going to
22
- https://codesandbox.io/s/9229wz40yo?fontsize=14.
23
- Paste a link here to your working reproduction.
@@ -1,5 +0,0 @@
1
- Thanks for submitting a pull request to React-Resizable!
2
-
3
- Please reference an open issue. If one has not been created, please create one along with a failing example or test case.
4
-
5
- Please do not commit built files (`/dist`) to pull requests. They are built only at release.