Skip to content

Commit 25bfa9a

Browse files
committed
Fix imgBounds only being re-calculated on body scroll
1 parent 7196442 commit 25bfa9a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Magnifier.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ export default class Magnifier extends PureComponent {
9898
this.img.addEventListener('touchmove', this.onTouchMove, { passive: false });
9999
this.img.addEventListener('touchend', this.onTouchEnd, { passive: false });
100100

101-
// Re-calculate image bounds on resize and scroll
101+
// Re-calculate image bounds on window resize
102102
window.addEventListener('resize', this.calcImgBoundsDebounced);
103-
window.addEventListener('scroll', this.calcImgBoundsDebounced);
103+
// Re-calculate image bounds on scroll (useCapture: catch scroll events in entire DOM)
104+
window.addEventListener('scroll', this.calcImgBoundsDebounced, true);
104105
}
105106

106107
componentWillUnmount() {

0 commit comments

Comments
 (0)