Skip to content

Commit

Permalink
Fix mixed up X and Y variables, fixes i-like-robots#131
Browse files Browse the repository at this point in the history
  • Loading branch information
i-like-robots committed May 15, 2020
1 parent 430fc26 commit be809bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions dist/easyzoom.js

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

14 changes: 7 additions & 7 deletions src/easyzoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,17 @@
}

var targetOffset = this.$target.offset();
var relativePositionX = pointerPositionY - targetOffset.top;
var relativePositionY = pointerPositionX - targetOffset.left;
var moveX = Math.ceil(relativePositionX * ratioY);
var moveY = Math.ceil(relativePositionY * ratioX);
var relativePositionX = pointerPositionX - targetOffset.left;
var relativePositionY = pointerPositionY - targetOffset.top;
var moveX = Math.ceil(relativePositionX * ratioX);
var moveY = Math.ceil(relativePositionY * ratioY);

// Close if outside
if (moveY < 0 || moveX < 0 || moveY > zoomImgOverlapX || moveX > zoomImgOverlapY) {
if (moveX < 0 || moveY < 0 || moveX > zoomImgOverlapX || moveY > zoomImgOverlapY) {
this.hide();
} else {
var top = moveX * -1;
var left = moveY * -1;
var top = moveY * -1;
var left = moveX * -1;

this.$zoom.css({
top: top,
Expand Down

0 comments on commit be809bf

Please sign in to comment.