Skip to content

Commit

Permalink
Rename useMovementInteraction to useMovable
Browse files Browse the repository at this point in the history
  • Loading branch information
benchristel committed Mar 7, 2024
1 parent 4b13620 commit dd968d6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 31 deletions.
42 changes: 21 additions & 21 deletions .api-report/mafs.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,27 @@ export type TransformProps = React_2.PropsWithChildren<{
shear?: vec.Vector2;
}>;

// @public (undocumented)
export interface UseMovable {
// (undocumented)
dragging: boolean;
}

// @public (undocumented)
export function useMovable(args: UseMovableArguments): UseMovable;

// @public (undocumented)
export interface UseMovableArguments {
// (undocumented)
constrain: (point: vec.Vector2) => vec.Vector2;
// (undocumented)
gestureTarget: React_2.RefObject<Element>;
// (undocumented)
onMove: (point: vec.Vector2) => unknown;
// (undocumented)
point: vec.Vector2;
}

// @public (undocumented)
export interface UseMovablePoint {
// (undocumented)
Expand All @@ -388,27 +409,6 @@ export interface UseMovablePointArguments {
constrain?: "horizontal" | "vertical" | ConstraintFunction;
}

// @public (undocumented)
export interface UseMovementInteraction {
// (undocumented)
dragging: boolean;
}

// @public (undocumented)
export function useMovementInteraction(args: UseMovementInteractionArguments): UseMovementInteraction;

// @public (undocumented)
export interface UseMovementInteractionArguments {
// (undocumented)
constrain: (point: vec.Vector2) => vec.Vector2;
// (undocumented)
gestureTarget: React_2.RefObject<Element>;
// (undocumented)
onMove: (point: vec.Vector2) => unknown;
// (undocumented)
point: vec.Vector2;
}

// Warning: (ae-forgotten-export) The symbol "PaneContextShape" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
Expand Down
6 changes: 3 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export type { MovablePointProps } from "./interaction/MovablePoint"
export { MovablePointDisplay } from "./display/MovablePointDisplay"
export type { MovablePointDisplayProps } from "./display/MovablePointDisplay"

export { useMovementInteraction } from "./interaction/useMovementInteraction"
export { useMovable } from "./interaction/useMovementInteraction"
export type {
UseMovementInteraction,
UseMovementInteractionArguments,
UseMovable,
UseMovableArguments,
} from "./interaction/useMovementInteraction"

export { useMovablePoint } from "./interaction/useMovablePoint"
Expand Down
4 changes: 2 additions & 2 deletions src/interaction/MovablePoint.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from "react"
import { Theme } from "../display/Theme"
import { vec } from "../vec"
import { useMovementInteraction } from "./useMovementInteraction"
import { useMovable } from "./useMovementInteraction"
import { MovablePointDisplay } from "../display/MovablePointDisplay"

export type ConstraintFunction = (position: vec.Vector2) => vec.Vector2
Expand Down Expand Up @@ -29,7 +29,7 @@ export function MovablePoint({
}: MovablePointProps) {
const ref = React.useRef<SVGGElement>(null)

const { dragging } = useMovementInteraction({ gestureTarget: ref, onMove, point, constrain })
const { dragging } = useMovable({ gestureTarget: ref, onMove, point, constrain })

return <MovablePointDisplay ref={ref} point={point} color={color} dragging={dragging} />
}
Expand Down
8 changes: 3 additions & 5 deletions src/interaction/useMovementInteraction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@ import { useSpanContext } from "../context/SpanContext"
import { useTransformContext } from "../context/TransformContext"
import { range } from "../math"

export interface UseMovementInteractionArguments {
export interface UseMovableArguments {
gestureTarget: React.RefObject<Element>
onMove: (point: vec.Vector2) => unknown
point: vec.Vector2
constrain: (point: vec.Vector2) => vec.Vector2
}

export interface UseMovementInteraction {
export interface UseMovable {
dragging: boolean
}

export function useMovementInteraction(
args: UseMovementInteractionArguments,
): UseMovementInteraction {
export function useMovable(args: UseMovableArguments): UseMovable {
const { gestureTarget: target, onMove, point, constrain } = args
const [dragging, setDragging] = React.useState(false)
const { xSpan, ySpan } = useSpanContext()
Expand Down

0 comments on commit dd968d6

Please sign in to comment.