Skip to content

Commit 3178a83

Browse files
committed
refactor(Resizable): just store the DOMRect as lastHandleRect
DOMRect is thankfully not a live object
1 parent 6f33d03 commit 3178a83

3 files changed

Lines changed: 4 additions & 10 deletions

File tree

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
// For Flow
3232
"ReactElement": false,
3333
"ReactClass": false,
34-
"SyntheticEvent": false
34+
"SyntheticEvent": false,
35+
"ClientRect": false
3536
}
3637
}

lib/Resizable.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {Node as ReactNode} from 'react';
44
import {DraggableCore} from 'react-draggable';
55
import {cloneElement} from './utils';
66
import {resizableProps} from "./propTypes";
7-
import type {ResizeHandleAxis, Props, ResizableState, DragCallbackData, ClientRect} from './propTypes';
7+
import type {ResizeHandleAxis, Props, ResizableState, DragCallbackData} from './propTypes';
88

99
export default class Resizable extends React.Component<Props, ResizableState> {
1010
static propTypes = resizableProps;
@@ -126,10 +126,7 @@ export default class Resizable extends React.Component<Props, ResizableState> {
126126
}
127127
}
128128
// Storage of last rect so we know how much it has really moved.
129-
this.lastHandleRect = {
130-
top: handleRect.top,
131-
left: handleRect.left,
132-
};
129+
this.lastHandleRect = handleRect;
133130

134131
// Reverse delta if using top or left drag handles.
135132
if (axisH === 'w') deltaX = -deltaX;

lib/propTypes.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ export type ResizeCallbackData = {|
2121
size: {|width: number, height: number|},
2222
handle: ResizeHandleAxis
2323
|};
24-
export type ClientRect = {|
25-
left: number;
26-
top: number;
27-
|};
2824

2925
// <Resizable>
3026
export type Props = {|

0 commit comments

Comments
 (0)