reorder
This commit is contained in:
@ -29,7 +29,17 @@ const useStyles = createStyles((theme) => ({
|
||||
}));
|
||||
|
||||
export interface DndListProps {
|
||||
data: {
|
||||
data: TData
|
||||
}
|
||||
|
||||
export interface IProps
|
||||
{
|
||||
dragEndHandler: (p: any) => void;
|
||||
dataprops: DndListProps;
|
||||
}
|
||||
|
||||
export type TData =
|
||||
{
|
||||
|
||||
id: string;
|
||||
name: string;
|
||||
@ -39,16 +49,9 @@ export interface DndListProps {
|
||||
// mass: number;
|
||||
// symbol: string;
|
||||
// name: string;
|
||||
}[];
|
||||
}
|
||||
}[]
|
||||
|
||||
export interface IProps
|
||||
{
|
||||
dragEndHandler: (p: any) => void;
|
||||
dataprops: DndListProps;
|
||||
}
|
||||
|
||||
const reorder = ({ from, to }: { from: number; to: number })
|
||||
const reorder = ({current, from, to }: {current: TData; from: number; to: number }) =>
|
||||
{
|
||||
const cloned = [...current];
|
||||
const item = current[from];
|
||||
@ -92,7 +95,13 @@ export interface DndListProps {
|
||||
{
|
||||
handlers.reorder({ from: source.index, to: destination?.index || 0 });
|
||||
console.log(state);
|
||||
dragEndHandler(state);
|
||||
dragEndHandler(
|
||||
reorder(
|
||||
{
|
||||
current:state,
|
||||
from: source.index,
|
||||
to: destination!.index
|
||||
} ));
|
||||
}
|
||||
}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user