Skip to content

Commit

Permalink
fix: stop loupe being shown in incorrect position on mouseenter (#113)
Browse files Browse the repository at this point in the history
* fix: stop width and height values being affected by transforms in ZoomPane

* chore: remove unused variable

* chore: remove console.logs
  • Loading branch information
frederickfogerty authored Nov 2, 2018
1 parent 7cc5f9e commit 710dfd7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/js/BoundingBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ export default class BoundingBox {
let inlineLeft = triggerRect.left + percentageOffsetX * triggerRect.width - this.el.clientWidth / 2 + pageXOffset;
let inlineTop = triggerRect.top + percentageOffsetY * triggerRect.height - this.el.clientHeight / 2 + pageYOffset;

let elRect = this.el.getBoundingClientRect();

if (inlineLeft < triggerRect.left + pageXOffset) {
inlineLeft = triggerRect.left + pageXOffset;
} else if (inlineLeft + this.el.clientWidth > triggerRect.left + triggerRect.width + pageXOffset) {
Expand Down
6 changes: 4 additions & 2 deletions src/js/ZoomPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ export default class ZoomPane {
// `percentageOffsetX` and `percentageOffsetY` must be percentages
// expressed as floats between `0' and `1`.
setPosition(percentageOffsetX, percentageOffsetY, triggerRect) {
const { width: imgElWidth, height: imgElHeight } = this.imgEl.getBoundingClientRect();
const { width: elWidth, height: elHeight } = this.el.getBoundingClientRect();
const imgElWidth = this.imgEl.offsetWidth;
const imgElHeight = this.imgEl.offsetHeight;
const elWidth = this.el.offsetWidth;
const elHeight = this.el.offsetHeight;

const centreOfContainerX = elWidth / 2;
const centreOfContainerY = elHeight / 2;
Expand Down

0 comments on commit 710dfd7

Please sign in to comment.