-
-
Notifications
You must be signed in to change notification settings - Fork 639
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to better support swappable
- Loading branch information
Clauderic Demers
committed
Oct 25, 2021
1 parent
5f7e58c
commit 94cd71d
Showing
9 changed files
with
84 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export {useSortable} from './useSortable'; | ||
export type {Arguments as UseSortableArguments} from './useSortable'; | ||
|
||
export {defaultAnimateLayoutChanges} from './defaults'; | ||
export type {AnimateLayoutChanges} from './types'; | ||
export {defaultAnimateLayoutChanges, defaultNewIndexGetter} from './defaults'; | ||
export type {AnimateLayoutChanges, NewIndexGetter} from './types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
export {SortableContext} from './components'; | ||
export type {SortableContextProps} from './components'; | ||
export {useSortable, defaultAnimateLayoutChanges} from './hooks'; | ||
export type {UseSortableArguments, AnimateLayoutChanges} from './hooks'; | ||
export { | ||
useSortable, | ||
defaultAnimateLayoutChanges, | ||
defaultNewIndexGetter, | ||
} from './hooks'; | ||
export type { | ||
UseSortableArguments, | ||
AnimateLayoutChanges, | ||
NewIndexGetter, | ||
} from './hooks'; | ||
export { | ||
horizontalListSortingStrategy, | ||
rectSortingStrategy, | ||
rectSwappingStrategy, | ||
verticalListSortingStrategy, | ||
} from './strategies'; | ||
export {sortableKeyboardCoordinates} from './sensors'; | ||
export {arrayMove} from './utilities'; | ||
export {arrayMove, arraySwap} from './utilities'; | ||
export type {SortingStrategy} from './types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Swap an array item to a different position. Returns a new array with the item swapped to the new position. | ||
*/ | ||
export function arraySwap<T>(array: T[], from: number, to: number): T[] { | ||
const newArray = array.slice(); | ||
|
||
newArray[from] = array[to]; | ||
newArray[to] = array[from]; | ||
|
||
return newArray; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export {arrayMove} from './arrayMove'; | ||
export {arraySwap} from './arraySwap'; | ||
export {getSortedRects} from './getSortedRects'; | ||
export {isValidIndex} from './isValidIndex'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters