diff --git a/.gitignore b/.gitignore index 4eb1ae11..d872a6ea 100644 --- a/.gitignore +++ b/.gitignore @@ -69,3 +69,5 @@ npm-debug.log dist lib static + +!src/lib diff --git a/src/lib/react-alice-carousel.tsx b/src/lib/react-alice-carousel.tsx index 4e755e7d..87fca882 100644 --- a/src/lib/react-alice-carousel.tsx +++ b/src/lib/react-alice-carousel.tsx @@ -1,7 +1,7 @@ import React from 'react'; import VS, { EventData } from 'vanilla-swipe'; import { defaultProps } from './defaultProps'; -import Link, { type LinkProps } from './views/DNDLink'; +import Link, { type LinkProps } from './views/Link'; import * as Views from './views'; import * as Utils from './utils'; import { diff --git a/src/lib/views/Link.tsx b/src/lib/views/Link.tsx new file mode 100644 index 00000000..847eb243 --- /dev/null +++ b/src/lib/views/Link.tsx @@ -0,0 +1,34 @@ +import React from 'react'; +import type { AnchorHTMLAttributes, PropsWithChildren, MouseEvent } from 'react'; + +export type LinkProps = PropsWithChildren>; + +export default function Link(props: LinkProps) { + const coords: Record = { + xDown: null, + xUp: null, + }; + + const handleOnMouseDown = (e: MouseEvent) => { + e.preventDefault(); + coords.xUp = null; + coords.xDown = e.clientX; + }; + + const handleMouseUp = (e: MouseEvent) => { + e.preventDefault(); + coords.xUp = e.clientX; + }; + + const handleOnClick = (e: MouseEvent) => { + if (coords.xDown !== coords.xUp) { + e.preventDefault(); + } + }; + + return ( + + {props.children} + + ); +}