react-multi-split-pane
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -9,2 +9,3 @@ import * as React from 'react'; | ||
onDragStarted?: () => void; | ||
onChange?: (sizes: number[]) => void; | ||
onDragFinished?: (sizes: number[]) => void; | ||
@@ -11,0 +12,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const { useCallback, useRef, useState, useMemo } = React; | ||
const { useCallback, useRef, useState, useMemo, useEffect } = React; | ||
const Pane_1 = require("./Pane"); | ||
@@ -66,3 +66,3 @@ const Resizer_1 = require("./Resizer"); | ||
function useSplitPaneResize(options) { | ||
const { children, split, defaultSizes, minSize: minSizes, onDragStarted, onDragFinished } = options; | ||
const { children, split, defaultSizes, minSize: minSizes, onDragStarted, onChange, onDragFinished } = options; | ||
const [sizes, setSizes] = useState(new Map()); | ||
@@ -91,2 +91,7 @@ const paneRefs = useRef(new Map()); | ||
const resizeState = dragState ? dragState.extraState : null; | ||
useEffect(() => { | ||
if (onChange && dragState) { | ||
onChange(movedSizes); | ||
} | ||
}, [dragState, movedSizes, onChange]); | ||
const childPanes = useMemo(() => { | ||
@@ -93,0 +98,0 @@ const prevPaneRefs = paneRefs.current; |
@@ -31,6 +31,6 @@ "use strict"; | ||
const onMouseUp = () => { | ||
setDragging(null); | ||
if (onDragFinished) { | ||
onDragFinished(dragState); | ||
} | ||
setDragging(null); | ||
}; | ||
@@ -37,0 +37,0 @@ return [dragState, onMouseUp]; |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"repository": { | ||
@@ -12,0 +12,0 @@ "type": "git", |
@@ -36,7 +36,2 @@ # React Multi Split Pane | ||
## Notes for updating from react-multi-split-pane v0.1.x | ||
All code has been cleaned up significantly by moving to React Hooks. Due to | ||
the restructuring, the `onChange` callback is not supported anymore. | ||
## Differences from [react-split-pane](https://github.com/tomkp/react-split-pane) | ||
@@ -78,2 +73,6 @@ | ||
### onChange: (sizes: number[]) => void | ||
This callback is invoked with the current drag during a drag event. It is | ||
recommended that it is wrapped in a debounce function. | ||
## Persisting Positions | ||
@@ -80,0 +79,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
30909
317
0
161