Skip to content

Commit 564a48d

Browse files
committed
feat(update): minor changes
1 parent f31a7d2 commit 564a48d

File tree

3 files changed

+5
-25
lines changed

3 files changed

+5
-25
lines changed

src/components/Droppable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const Droppable: FunctionComponent<PropsWithChildren<DroppableProps>> = (
3838
animatedStyleWorklet,
3939
...otherProps
4040
}) => {
41-
const { setNodeRef, setNodeLayout, activeId } = useDroppable({
41+
const { animatedRef, setNodeLayout, activeId } = useDroppable({
4242
id,
4343
disabled,
4444
data,
@@ -56,7 +56,7 @@ export const Droppable: FunctionComponent<PropsWithChildren<DroppableProps>> = (
5656
}, [id, activeOpacity]);
5757

5858
return (
59-
<Animated.View ref={setNodeRef} onLayout={setNodeLayout} style={[style, animatedStyle]} {...otherProps}>
59+
<Animated.View ref={animatedRef} onLayout={setNodeLayout} style={[style, animatedStyle]} {...otherProps}>
6060
{children}
6161
</Animated.View>
6262
);

src/hooks/useDraggable.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@
22

33
import { useLayoutEffect } from "react";
44
import { LayoutRectangle, ViewProps } from "react-native";
5-
import {
6-
measure,
7-
runOnUI,
8-
useAnimatedReaction,
9-
useAnimatedRef,
10-
useSharedValue,
11-
} from "react-native-reanimated";
5+
import { runOnUI, useAnimatedReaction, useAnimatedRef, useSharedValue } from "react-native-reanimated";
126
import { DraggableState, useDndContext } from "../DndContext";
137
import { useLatestSharedValue } from "../hooks";
148
import { Data, UniqueIdentifier } from "../types";
15-
import { getLayoutFromMeasurement, isReanimatedSharedValue, updateLayoutValue, waitForLayout } from "../utils";
9+
import { isReanimatedSharedValue, updateLayoutValue, waitForLayout } from "../utils";
1610
import { useSharedPoint } from "./useSharedPoint";
1711

1812
export type DraggableConstraints = {
@@ -39,14 +33,6 @@ export type UseDraggableOptions = Partial<DraggableConstraints> & {
3933
* @param {boolean} [options.disabled=false] - A flag that indicates whether the draggable component is disabled.
4034
* @param {number} [options.activationDelay=0] - A number representing the duration, in milliseconds, that this draggable item needs to be held for before allowing a drag to start.
4135
* @param {number} [options.activationTolerance=Infinity] - A number representing the distance, in points, of motion that is tolerated before the drag operation is aborted.
42-
*
43-
* @returns {object} Returns an object with properties and methods related to the draggable component.
44-
* @property {object} offset - An object representing the current offset of the draggable component.
45-
* @property {Function} setNodeRef - A function that can be used to set the ref of the draggable component.
46-
* @property {string} activeId - The unique identifier of the currently active draggable component.
47-
* @property {string} actingId - The unique identifier of the currently interacti draggable component.
48-
* @property {Function} setNodeLayout - A function that handles the layout event of the draggable component.
49-
* @property {object} draggableState - An object representing the current state of the draggable component.
5036
*/
5137
export const useDraggable = ({
5238
id,

src/hooks/useDroppable.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ export type UseDroppableOptions = { id: UniqueIdentifier; data?: Data; disabled?
2121
* @param {string} options.id - A unique identifier for the droppable component.
2222
* @param {object} [options.data={}] - Optional data associated with the droppable component.
2323
* @param {boolean} [options.disabled=false] - A flag that indicates whether the droppable component is disabled.
24-
*
25-
* @returns {object} Returns an object with properties and methods related to the droppable component.
26-
* @property {Function} setNodeRef - A function that can be used to set the ref of the droppable component.
27-
* @property {Function} setNodeLayout - A function that handles the layout event of the droppable component.
28-
* @property {string} activeId - The unique identifier of the currently active droppable component.
29-
* @property {object} panGestureState - An object representing the current state of the draggable component within the context.
3024
*/
3125
export const useDroppable = ({ id, data = {}, disabled = false }: UseDroppableOptions) => {
3226
const { droppableLayouts, droppableOptions, droppableActiveId, panGestureState } = useDndContext();
@@ -47,7 +41,7 @@ export const useDroppable = ({ id, data = {}, disabled = false }: UseDroppableOp
4741
waitForLayout(() => {
4842
// Try to recover the layout from the ref if it's not available yet
4943
if (layout.value.width === 0 || layout.value.height === 0) {
50-
console.log(`Recovering layout for ${id} from ref`);
44+
// console.log(`Recovering layout for ${id} from ref`);
5145
updateLayoutValue(layout, animatedRef);
5246
}
5347
droppableLayouts.value[id] = layout;

0 commit comments

Comments
 (0)