Skip to content

Commit

Permalink
Merge pull request #434 from eych/fix/zoom_behavior_and_overlay_heigh…
Browse files Browse the repository at this point in the history
…t_in_safari

Fixes for the zoom behaviour and overlay height in iOS Safari
  • Loading branch information
rpearce committed Aug 2, 2023
2 parents da1404d + 6f8e96d commit 336416f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```
$ git remote add upstream git@github.com:rpearce/react-medium-image-zoom.git
$ git fetch upstream
$ git rebase upstream/master
$ git rebase upstream/main
```
1. Check out a feature branch
```
Expand All @@ -19,12 +19,12 @@
$ git push origin my-feature
```
1. Create a [pull request](https://help.github.com/articles/about-pull-requests/)
from your branch to this repo's `master` branch
1. When all is merged, pull down the upstream changes to your `master`
from your branch to this repo's `main` branch
1. When all is merged, pull down the upstream changes to your `main`
```
$ git checkout master
$ git checkout main
$ git fetch upstream
$ git rebase upstream/master
$ git rebase upstream/main
```
1. Delete your feature branch (locally and then on GitHub)
```
Expand Down
9 changes: 6 additions & 3 deletions source/Controlled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class ControlledBase extends Component<ControlledPropsWithDefaults, ControlledSt
this.refModalImg.current?.removeEventListener?.('transitionend', this.handleUnzoomEnd)
window.removeEventListener('wheel', this.handleWheel)
window.removeEventListener('touchstart', this.handleTouchStart)
window.removeEventListener('touchend', this.handleTouchMove)
window.removeEventListener('touchmove', this.handleTouchMove)
window.removeEventListener('touchcancel', this.handleTouchCancel)
window.removeEventListener('resize', this.handleResize)
document.removeEventListener('keydown', this.handleKeyDown, true)
Expand Down Expand Up @@ -515,6 +515,9 @@ class ControlledBase extends Component<ControlledPropsWithDefaults, ControlledSt
* Unzoom on wheel event
*/
handleWheel = (e: WheelEvent) => {
// don't handle the event when the user is zooming with ctrl + wheel (or with pinch to zoom)
if (e.ctrlKey) return

e.stopPropagation()
queueMicrotask(() => {
this.handleUnzoom()
Expand Down Expand Up @@ -581,7 +584,7 @@ class ControlledBase extends Component<ControlledPropsWithDefaults, ControlledSt

window.addEventListener('wheel', this.handleWheel, { passive: true })
window.addEventListener('touchstart', this.handleTouchStart, { passive: true })
window.addEventListener('touchend', this.handleTouchMove, { passive: true })
window.addEventListener('touchmove', this.handleTouchMove, { passive: true })
window.addEventListener('touchcancel', this.handleTouchCancel, { passive: true })
document.addEventListener('keydown', this.handleKeyDown, true)

Expand Down Expand Up @@ -609,7 +612,7 @@ class ControlledBase extends Component<ControlledPropsWithDefaults, ControlledSt

window.removeEventListener('wheel', this.handleWheel)
window.removeEventListener('touchstart', this.handleTouchStart)
window.removeEventListener('touchend', this.handleTouchMove)
window.removeEventListener('touchmove', this.handleTouchMove)
window.removeEventListener('touchcancel', this.handleTouchCancel)
document.removeEventListener('keydown', this.handleKeyDown, true)

Expand Down
4 changes: 2 additions & 2 deletions source/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
[data-rmiz-modal][open] {
position: fixed;
width: 100vw;
width: 100svw;
width: 100dvw;
height: 100vh;
height: 100svh;
height: 100dvh;
max-width: none;
max-height: none;
margin: 0;
Expand Down

0 comments on commit 336416f

Please sign in to comment.