|
1 | 1 | import * as React from 'react'; |
2 | | -import { Motion, spring } from 'react-motion'; |
| 2 | +import { Motion, spring, SpringHelperConfig } from 'react-motion'; |
3 | 3 | import { ResizableDirection } from 're-resizable'; |
4 | 4 | import ResizeObserver from 'resize-observer-polyfill'; |
5 | 5 | import isEqual from 'lodash.isequal'; |
@@ -31,13 +31,7 @@ const directionDict: { [key: string]: PaneResizeDirection } = { |
31 | 31 |
|
32 | 32 | const clamp = (n: number, min = n, max = n): number => Math.max(Math.min(n, max), min); |
33 | 33 |
|
34 | | -type Spring = { |
35 | | - damping?: number; |
36 | | - stiffness?: number; |
37 | | - precision?: number; |
38 | | -}; |
39 | | - |
40 | | -const springConfig: Spring = { |
| 34 | +const defaultSpringConfig: SpringHelperConfig = { |
41 | 35 | damping: 30, |
42 | 36 | stiffness: 500, |
43 | 37 | }; |
@@ -93,6 +87,7 @@ export type SortablePaneProps = { |
93 | 87 | dragHandleClassName?: string; |
94 | 88 | defaultOrder?: string[]; |
95 | 89 | order?: string[]; |
| 90 | + springConfig?: SpringHelperConfig, |
96 | 91 | children: React.ReactElement<PaneProps>[]; |
97 | 92 | }; |
98 | 93 |
|
@@ -127,6 +122,7 @@ class SortablePane extends React.Component<SortablePaneProps, State> { |
127 | 122 | className: '', |
128 | 123 | disableEffect: false, |
129 | 124 | isSortable: true, |
| 125 | + springConfig: defaultSpringConfig |
130 | 126 | }; |
131 | 127 |
|
132 | 128 | constructor(props: SortablePaneProps) { |
@@ -516,7 +512,7 @@ class SortablePane extends React.Component<SortablePaneProps, State> { |
516 | 512 |
|
517 | 513 | renderPanes() { |
518 | 514 | const { mouse, isPressed, lastPressed, isResizing } = this.state; |
519 | | - const { disableEffect, isSortable } = this.props; |
| 515 | + const { disableEffect, isSortable, springConfig } = this.props; |
520 | 516 | const children = this.props.children || []; |
521 | 517 | return children.map((child, i) => { |
522 | 518 | const pos = this.props.order |
|
0 commit comments