Skip to content

Commit

Permalink
Merge pull request #172 from the-deep/fix/disable-scroll-zoom
Browse files Browse the repository at this point in the history
Add props for disabling image zoom on scroll
  • Loading branch information
AdityaKhatri authored Jul 9, 2024
2 parents a15e881 + 6ee0463 commit 9480169
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@the-deep/deep-ui",
"version": "2.0.7-beta.1",
"version": "2.0.7-beta.2",
"description": "React component library by Deep",
"files": [
"/build"
Expand Down
7 changes: 6 additions & 1 deletion src/components/ImagePreview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface Props {
src: HTMLImageProps['src'];
alt: HTMLImageProps['alt'];
hideTools?: boolean;
disableZoomOnScroll?: boolean;
}

function ImagePreview(props: Props) {
Expand All @@ -35,6 +36,7 @@ function ImagePreview(props: Props) {
src,
alt,
hideTools,
disableZoomOnScroll,
} = props;

const [expanded, , setExpandedFalse, , toggleExpanded] = useBooleanState(false);
Expand Down Expand Up @@ -65,7 +67,10 @@ function ImagePreview(props: Props) {
>
{pending && <PendingMessage />}
<TransformWrapper
wheel={{ step: 0.2 }}
wheel={{
step: 0.2,
wheelDisabled: disableZoomOnScroll,
}}
centerZoomedOut
centerOnInit
minScale={0.2}
Expand Down
6 changes: 6 additions & 0 deletions storybook/stories/ImagePreview.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ Default.args = {
// alt: 'Image cannot be loaded',
};

export const NoZoomOnScroll = Template.bind({});
NoZoomOnScroll.args = {
src: 'https://i.imgur.com/5ehANlp.jpg',
disableZoomOnScroll: true,
};

export const WithoutImage = Template.bind({});
WithoutImage.args = {
src: '',
Expand Down

0 comments on commit 9480169

Please sign in to comment.