Skip to content

Commit

Permalink
Merge pull request #133 from sasza2/develop
Browse files Browse the repository at this point in the history
v1.11.0
  • Loading branch information
sasza2 authored Nov 6, 2023
2 parents 4b5bf3e + a22c014 commit 391d3fe
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sasza/react-panzoom",
"version": "1.10.4",
"version": "1.11.0",
"description": "React component for pan and zoom with possibility to moving, resizing and selecting elements inside",
"main": "dist/main.umd.cjs",
"module": "./dist/main.js",
Expand Down Expand Up @@ -67,6 +67,6 @@
"react": ">=16.14.0"
},
"dependencies": {
"panzoom-core": "1.3.3"
"panzoom-core": "1.4.0"
}
}
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/Element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Element: React.FC<ElementProps> = ({
id,
onAfterResize,
onClick,
onContextMenu,
onMouseUp,
resizable,
resizedMaxWidth,
Expand All @@ -38,6 +39,7 @@ const Element: React.FC<ElementProps> = ({
height,
onAfterResize,
onClick,
onContextMenu,
onMouseUp,
resizable,
resizedMaxWidth,
Expand All @@ -56,7 +58,7 @@ const Element: React.FC<ElementProps> = ({
}, [initialized]);

useDidUpdateEffect(() => {
if (!initialized || !elementRef.current) return
if (!initialized || !elementRef.current) return;
elementRef.current.setOptions(options);
}, [
disabled,
Expand All @@ -68,6 +70,7 @@ const Element: React.FC<ElementProps> = ({
id,
onAfterResize,
onClick,
onContextMenu,
onMouseUp,
resizable,
resizedMaxWidth,
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ElementProps, PanZoomPropsRef, PanZoomWithCoverPropsRef } from './types';

export { API, PanZoomOptions } from './types';
export { API, ElementOptions, PanZoomOptions } from './types';

export default function PanZoom(props: PanZoomPropsRef): JSX.Element;

Expand Down
16 changes: 16 additions & 0 deletions types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ type OnContainerClick = (
} & Position
) => unknown;

type OnContextMenu = (
click: {
e: MouseEvent;
} & Position
) => unknown;

export type Zoom = Ref<number>;

export type PanZoomOptions = {
Expand All @@ -64,6 +70,7 @@ export type PanZoomOptions = {
disabledUserSelect?: boolean;
disabledZoom?: boolean;
elementsAutoMoveAtEdge?: boolean;
onContextMenu?: OnContextMenu;
onElementsChange?: OnElementsChange;
onContainerChange?: OnContainerChange;
onContainerClick?: OnContainerClick,
Expand Down Expand Up @@ -134,6 +141,14 @@ type ElementOnMouseUp = (
} & Position
) => unknown;

type ElementOnContextMenu = (
props: {
id: ElementId;
family?: string;
e: MouseEvent;
} & Position
) => unknown;

export type ElementOptions = {
className?: string;
disabled?: boolean;
Expand All @@ -144,6 +159,7 @@ export type ElementOptions = {
id: ElementId;
onAfterResize?: ElementOnAfterResize;
onClick?: ElementOnClick;
onContextMenu?: ElementOnContextMenu;
onMouseUp?: ElementOnMouseUp;
resizable?: boolean;
resizedMaxWidth?: number;
Expand Down

0 comments on commit 391d3fe

Please sign in to comment.