Skip to content

Commit f101283

Browse files
committed
fix(types): Flow: make properties of DraggableBounds optional
1 parent a227eba commit f101283

File tree

5 files changed

+7
-14
lines changed

5 files changed

+7
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ axis: string,
176176
// - An object with `left, top, right, and bottom` properties.
177177
// These indicate how far in each direction the draggable
178178
// can be moved.
179-
bounds: {left: number, top: number, right: number, bottom: number} | string,
179+
bounds: {left?: number, top?: number, right?: number, bottom?: number} | string,
180180

181181
// Specifies a selector to be used to prevent drag initialization. The string is passed to
182182
// Element.matches, so it's possible to use multiple selectors like `.first, .second`.

lib/Draggable.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import {createCSSTransform, createSVGTransform} from './utils/domFns';
77
import {canDragX, canDragY, createDraggableData, getBoundPosition} from './utils/positionFns';
88
import {dontSetMe} from './utils/shims';
99
import DraggableCore from './DraggableCore';
10-
import type {ControlPosition, PositionOffsetControlPosition, DraggableBounds, DraggableCoreProps} from './DraggableCore';
10+
import type {ControlPosition, PositionOffsetControlPosition, DraggableCoreProps} from './DraggableCore';
1111
import log from './utils/log';
12-
import type {DraggableEventHandler} from './utils/types';
12+
import type {Bounds, DraggableEventHandler} from './utils/types';
1313
import type {Element as ReactElement} from 'react';
1414

1515
type DraggableState = {
@@ -24,7 +24,7 @@ type DraggableState = {
2424
export type DraggableProps = {
2525
...$Exact<DraggableCoreProps>,
2626
axis: 'both' | 'x' | 'y' | 'none',
27-
bounds: DraggableBounds | string | false,
27+
bounds: Bounds | string | false,
2828
defaultClassName: string,
2929
defaultClassNameDragging: string,
3030
defaultClassNameDragged: string,

lib/DraggableCore.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,6 @@ type DraggableCoreState = {
3535
touchIdentifier: ?number
3636
};
3737

38-
export type DraggableBounds = {
39-
left: number,
40-
right: number,
41-
top: number,
42-
bottom: number,
43-
};
44-
4538
export type DraggableData = {
4639
node: HTMLElement,
4740
x: number, y: number,

lib/utils/shims.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ export function findInArray(array: Array<any> | TouchList, callback: Function):
66
}
77
}
88

9-
export function isFunction(func: any): boolean {
9+
export function isFunction(func: any): boolean %checks {
1010
return typeof func === 'function' || Object.prototype.toString.call(func) === '[object Function]';
1111
}
1212

13-
export function isNum(num: any): boolean {
13+
export function isNum(num: any): boolean %checks {
1414
return typeof num === 'number' && !isNaN(num);
1515
}
1616

lib/utils/types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type DraggableData = {
1111
};
1212

1313
export type Bounds = {
14-
left: number, top: number, right: number, bottom: number
14+
left?: number, top?: number, right?: number, bottom?: number
1515
};
1616
export type ControlPosition = {x: number, y: number};
1717
export type PositionOffsetControlPosition = {x: number|string, y: number|string};

0 commit comments

Comments
 (0)