Skip to content

Commit

Permalink
Added pinch-to-zoom to presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dkvovik committed Jul 8, 2024
1 parent 124d2a2 commit 94eab00
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 21 deletions.
16 changes: 15 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion packages/presentation/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ulms/ui-presentation",
"version": "1.9.1",
"version": "1.10.0",
"license": "MIT",
"main": "index.js",
"module": "es/index.js",
Expand All @@ -19,6 +19,7 @@
"react-intl": "^5.21.0",
"react-sizeme": "^2.6.7",
"react-visibility-sensor": "^5.0.2",
"react-zoom-pan-pinch": "^3.4.4",
"scroll-into-view-if-needed": "^2.2.20"
},
"devDependencies": {
Expand Down
46 changes: 27 additions & 19 deletions packages/presentation/src/presentation.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable max-len, react/prop-types, jsx-a11y/no-static-element-interactions, react/jsx-one-expression-per-line,max-classes-per-file */
/* eslint-disable max-len, react/prop-types, jsx-a11y/no-static-element-interactions, react/jsx-one-expression-per-line,max-classes-per-file,react/jsx-props-no-spreading */
import React from 'react'
import { injectIntl, IntlProvider } from 'react-intl'
import VisibilitySensor from 'react-visibility-sensor'
Expand All @@ -8,6 +8,7 @@ import scrollIntoView from 'scroll-into-view-if-needed'
import { Icons } from '@ulms/ui-icons'
import { SizeMe } from 'react-sizeme'
import { Spinner } from '@ulms/ui-spinner'
import { TransformWrapper, TransformComponent } from 'react-zoom-pan-pinch'

import { messagesIntl } from '../lang/index'

Expand Down Expand Up @@ -155,6 +156,7 @@ class PresentationComponent extends React.Component {
showPagesCount,
showPreviews,
slotSlide,
transformWrapperProps,
} = this.props

return (
Expand Down Expand Up @@ -234,24 +236,31 @@ class PresentationComponent extends React.Component {
ref={innerRef}
data-id="presentation-slide"
>
<img
alt="mainimage"
className={cx(css.mainImage, {
[css[`centered${centered}`]]: !fitToWidth,
})}
src={collection[index].image}
width={imageSize.width}
height={imageSize.height}
/>
{slotSlide && (
<div
className={cx(css.slotSlide, {
[css[`centered${centered}`]]: !fitToWidth,
})}
<TransformWrapper disabled {...transformWrapperProps}>
<TransformComponent
contentClass={css.transformComponent}
wrapperClass={css.transformWrapper}
>
{slotSlide(imageSize.width, imageSize.height)}
</div>
)}
<img
alt="mainimage"
className={cx(css.mainImage, {
[css[`centered${centered}`]]: !fitToWidth,
})}
src={collection[index].image}
width={imageSize.width}
height={imageSize.height}
/>
{slotSlide && (
<div
className={cx(css.slotSlide, {
[css[`centered${centered}`]]: !fitToWidth,
})}
>
{slotSlide(imageSize.width, imageSize.height)}
</div>
)}
</TransformComponent>
</TransformWrapper>
</div>
)
} else {
Expand Down Expand Up @@ -353,7 +362,6 @@ export class PresentationIntl extends React.PureComponent {
locale={locale}
messages={messagesIntl[locale]}
>
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
<PresentationComponentIntl {...props} innerRef={innerRef} />
</IntlProvider>
)
Expand Down
6 changes: 6 additions & 0 deletions packages/presentation/src/presentation.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,9 @@
vertical-align: text-top;
line-height: 1em;
}

.transformWrapper,
.transformComponent {
height: 100% !important;
width: 100% !important;
}

0 comments on commit 94eab00

Please sign in to comment.