Skip to content

Commit

Permalink
Fix: Fullzoom button not filling window (#1442)
Browse files Browse the repository at this point in the history
* Fix: Fullzoom not filling window

* Made zoom guranteed to match window size

* update depreciated variable

* Update comment

* Update hoverzoom.js

---------

Co-authored-by: Oleg Anashkin <[email protected]>
  • Loading branch information
LiliaDoe and extesy authored Oct 31, 2024
1 parent 8e033f6 commit f0a064a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions js/hoverzoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,13 @@ var hoverZoom = {
}

// width adjustment
var fullZoom = options.mouseUnderlap || fullZoomKeyDown || viewerLocked;
const fullZoom = options.mouseUnderlap || viewerLocked;
const fullZoomKey = fullZoomKeyDown;
if (viewerLocked) {
imgFullSize.width(srcDetails.naturalWidth * zoomFactor);
} else if (fullZoomKey) {
// naturalWidth replaced with wndWidth to make image fill window
imgFullSize.width(Math.min(wndWidth, wndWidth - padding - 2 * scrollBarWidth));
} else if (fullZoom) {
imgFullSize.width(Math.min(srcDetails.naturalWidth * zoomFactor, wndWidth - padding - 2 * scrollBarWidth));
} else if (displayOnRight) {
Expand Down Expand Up @@ -2345,7 +2349,7 @@ var hoverZoom = {
// for instance, on TripAdvisor:
// img's src placeholder is replaced by real img url stored in data-lazyurl as user scrolls down
$(document).on('scroll mousewheel', function() {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop; // Credits: "https://github.com/qeremy/so/blob/master/so.dom.js#L426"
let scrollTop = window.scrollY || document.documentElement.scrollTop; // Credits: "https://github.com/qeremy/so/blob/master/so.dom.js#L426"
if (scrollTop < lastScrollTop) {
lastScrollTop = scrollTop < 0 ? 0 : scrollTop; // For Mobile or negative scrolling
} else if (scrollTop > lastScrollTop + deltaMin) {
Expand Down

0 comments on commit f0a064a

Please sign in to comment.