@vue-dnd-kit/utilities
Version:
Utilities for Vue DnD Kit - a lightweight Vue 3 library for building performant and accessible drag and drop interfaces
33 lines (31 loc) • 1.23 kB
TypeScript
import { Ref } from 'vue';
import { IPoint } from '@vue-dnd-kit/core';
/**
* Hook for calculating geometric relationships between two points.
* Independent utility that can be used for any geometric calculations,
* commonly used in drag and drop but not limited to it.
*
* @param pointA - Reference to the first point coordinates
* @param pointB - Reference to the second point coordinates
* @returns Object containing geometric calculations:
* - delta: difference between points
* - direction: cardinal direction from pointA to pointB
* - distance: euclidean distance between points
* - angle: angle in degrees between points
*
* @example
* ```ts
* const start = ref<IPoint>({ x: 0, y: 0 });
* const end = ref<IPoint>({ x: 100, y: 100 });
* const { delta, direction, distance, angle } = useGeometry(start, end);
* ```
*/
export declare const useGeometry: (pointA: Ref<IPoint | null>, pointB: Ref<IPoint | null>) => {
delta: import('vue').ComputedRef<{
x: number;
y: number;
}>;
direction: import('vue').ComputedRef<"up" | "right" | "down" | "left">;
distance: import('vue').ComputedRef<number>;
angle: import('vue').ComputedRef<number>;
};