dragjs
Version:
Simple utility to make it easier to implement drag based things (ie. sliders and such)
42 lines (41 loc) • 966 B
TypeScript
/// <reference lib="dom" />
declare type Callback = ({ x, y, cursor, elem, pointer }: {
x: number;
y: number;
cursor: Coordinate;
elem: HTMLElement;
e: MouseEvent | TouchEvent;
pointer?: HTMLElement;
}) => boolean | void;
declare type Callbacks = {
begin?: Callback;
change?: Callback;
end?: Callback;
};
declare type Position = "left" | "right";
declare function draggable({ element, handle, xPosition }: {
element: HTMLElement;
handle?: HTMLElement;
xPosition?: Position;
}, cbs?: Callbacks): void;
declare function xyslider(o: {
parent: HTMLElement;
class: string;
cbs: Callbacks;
}): {
background: HTMLElement;
pointer: HTMLElement;
};
declare function slider(o: {
parent: HTMLElement;
class: string;
cbs: Callbacks;
}): {
background: HTMLElement;
pointer: HTMLElement;
};
declare type Coordinate = {
x: number;
y: number;
};
export { draggable, slider, xyslider };