Skip to content

Commit

Permalink
fix(zoom): consider window scroll for offsets
Browse files Browse the repository at this point in the history
Fixes #4039
  • Loading branch information
nolimits4web committed Jan 25, 2021
1 parent 1c29964 commit 60cd60a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/zoom/zoom.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getWindow } from 'ssr-window';
import $ from '../../utils/dom';
import { bindModuleMethods, getTranslate } from '../../utils/utils';

Expand Down Expand Up @@ -290,6 +291,7 @@ const Zoom = {
},
in(e) {
const swiper = this;
const window = getWindow();

const zoom = swiper.zoom;
const params = swiper.params.zoom;
Expand Down Expand Up @@ -340,8 +342,8 @@ const Zoom = {
if (e) {
slideWidth = gesture.$slideEl[0].offsetWidth;
slideHeight = gesture.$slideEl[0].offsetHeight;
offsetX = gesture.$slideEl.offset().left;
offsetY = gesture.$slideEl.offset().top;
offsetX = gesture.$slideEl.offset().left + window.scrollX;
offsetY = gesture.$slideEl.offset().top + window.scrollY;
diffX = offsetX + slideWidth / 2 - touchX;
diffY = offsetY + slideHeight / 2 - touchY;

Expand Down

0 comments on commit 60cd60a

Please sign in to comment.