Skip to content

Commit

Permalink
fix(📦): Fix typings (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored May 2, 2019
1 parent 86124f7 commit 3098cc0
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/Interactable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ interface InteractableProps {
animatedValueY?: any;
style?: StyleProp<ViewStyle>;
dragEnabled: boolean;
onSnap: (e: { nativeEvent: SnapPoint & { index: number } }) => void;
onStop: (e: { nativeEvent: { x: number, y: number } }) => void;
onDrag: (e: { nativeEvent: { x: number, y: number, state: "start" | "end" } }) => void;
onSnap?: (e: { nativeEvent: SnapPoint & { index: number } }) => void;
onStop?: (e: { nativeEvent: { x: number, y: number } }) => void;
onDrag?: (e: { nativeEvent: { x: number, y: number, state: "start" | "end" } }) => void;
initialPosition: Position;
dragToss: number;
dragWithSpring?: {tension: number, damping: number};
Expand Down Expand Up @@ -396,7 +396,10 @@ export default class Interactable extends React.PureComponent<InteractableProps>
}

const handleStartDrag = props.onDrag
&& call([target.x, target.y], ([x, y]) => props.onDrag({ nativeEvent: { x, y, state: "start" } }));
&& call(
[target.x, target.y],
([x, y]) => props.onDrag && props.onDrag({ nativeEvent: { x, y, state: "start" } }),
);

const snapBuckets: [any[], any[], any[]] = [[], [], []];
const snapAnchor = {
Expand Down Expand Up @@ -480,10 +483,10 @@ export default class Interactable extends React.PureComponent<InteractableProps>
),
block([
props.onStop
&& cond(
? cond(
clockRunning(clock),
call([target.x, target.y], ([x, y]) => props.onStop({ nativeEvent: { x, y } })),
),
call([target.x, target.y], ([x, y]) => props.onStop && props.onStop({ nativeEvent: { x, y } })),
) : [],
stopClock(clock),
]),
startClock(clock),
Expand Down Expand Up @@ -522,12 +525,12 @@ export default class Interactable extends React.PureComponent<InteractableProps>
const step = cond(
eq(state, State.ACTIVE),
[
cond(dragging, 0, [
handleStartDrag,
cond(dragging, 0, block([
handleStartDrag || [],
startClock(clock),
set(dragging, 1),
set(start, x),
]),
])),
set(anchor, add(start, drag)),
cond(dt, dragBehaviors[axis]),
],
Expand Down

0 comments on commit 3098cc0

Please sign in to comment.