Skip to content

Commit

Permalink
feat: Add onClick to usePan (#619)
Browse files Browse the repository at this point in the history
* added onclick to usepan

* Revert "added onclick to usepan"

This reverts commit de8037b.

* Added onClick event to usePan
  • Loading branch information
dvmoritzschoefl authored Nov 5, 2024
1 parent d44d7f0 commit fead1c4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/vis/vishooks/hooks/usePan.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable react-compiler/react-compiler */
import * as React from 'react';
import { Direction, ZoomTransform } from '../interfaces';
import { useInteractions } from './useInteractions';
import { useInteractions, UseInteractionsProps } from './useInteractions';
import { useControlledUncontrolled } from './useControlledUncontrolled';
import { defaultConstraint } from '../transform';
import { m4 } from '../math';
Expand All @@ -20,6 +21,8 @@ interface UsePanProps {
*/
direction?: Direction;

onClick?: NonNullable<UseInteractionsProps['onClick']>;

skip?: boolean;
}

Expand All @@ -34,8 +37,9 @@ export function usePan(options: UsePanProps = {}) {
const zoomRef = React.useRef<UsePanProps['value']>(zoom);
zoomRef.current = zoom;

const { ref, setRef } = useInteractions({
const { ref, setRef, state } = useInteractions({
skip: options.skip,
onClick: options.onClick,
onDrag: (event) => {
let newMatrix = m4.clone(zoomRef.current);

Expand All @@ -59,5 +63,5 @@ export function usePan(options: UsePanProps = {}) {
},
});

return { ref, setRef, value: zoom, setValue: setZoom };
return { ref, setRef, value: zoom, setValue: setZoom, state };
}

0 comments on commit fead1c4

Please sign in to comment.