Skip to content

Commit

Permalink
Make small adjustements
Browse files Browse the repository at this point in the history
  • Loading branch information
blazejkustra committed Aug 31, 2023
1 parent 553053a commit f2dc8e3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/components/DraggableList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import {ScrollView} from 'react-native';
import useDraggableInPortal from './useDraggableInPortal';
import type {DraggableListProps, DefaultItemProps} from './types';

type ReoderParams<T> = {
type ReorderParams<T> = {
list: T[];
startIndex: number;
endIndex: number;
};

// Function to help us with reordering the result
const reorder = <T,>({list, startIndex, endIndex}: ReoderParams<T>): T[] => {
const reorder = <T,>({list, startIndex, endIndex}: ReorderParams<T>): T[] => {
const result = Array.from(list);
const [removed] = result.splice(startIndex, 1);

Expand Down
2 changes: 1 addition & 1 deletion src/components/DraggableList/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type DraggableListProps<T extends DefaultItemProps> = {
renderItem: (params: RenderItemParams<T>) => React.ReactNode;
onDragEnd?: (params: {data: T[]}) => void;
onDragBegin?: () => void;
onPlaceholderIndexChange?: ((placeholderIndex: number) => void);
onPlaceholderIndexChange?: (placeholderIndex: number) => void;
renderClone?: DraggableChildrenFn;
shouldUsePortal?: boolean;
onContentSizeChange?: ((w: number, h: number) => void) | undefined;
Expand Down
6 changes: 3 additions & 3 deletions src/components/DraggableList/useDraggableInPortal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {DraggableChildrenFn, DraggingStyle} from 'react-beautiful-dnd';
import type {DraggableChildrenFn} from 'react-beautiful-dnd';
import {useEffect, useRef} from 'react';
import {createPortal} from 'react-dom';

Expand Down Expand Up @@ -32,8 +32,8 @@ export default function useDraggableInPortal({shouldUsePortal}: DraggableInPorta

return (render) => (provided, snapshot, rubric) => {
const result = render(provided, snapshot, rubric);
const style = provided.draggableProps.style as DraggingStyle;
if (style.position === 'fixed') {
const style = provided.draggableProps.style;
if (style && 'position' in style && style.position === 'fixed') {
return createPortal(result, element);
}
return result;
Expand Down

0 comments on commit f2dc8e3

Please sign in to comment.