jackmoore / zoom

jQuery plugin for zooming images on mouseover.
http://www.jacklmoore.com/zoom/
MIT License
1.54k stars 460 forks source link

Prevent hidden image from affecting layout of page #116

Closed sehsarah closed 1 year ago

sehsarah commented 7 years ago

Fade invisible element to display: none

Fade invisible element to display: none by using fadeOut rather than fadeTo (which currently leaves the hidden opacity 0 elements on page so can mouseover them etc)

From the docs http://api.jquery.com/fadeout/

The .fadeOut() method animates the opacity of the matched elements. Once the opacity reaches 0, the display style property is set to none, so the element no longer affects the layout of the page.

No other functionality changes except for opacity: 0 elements are also display: none with this change


My issue without this patch

Therefore this patch fixes my issue


Hope this helps someone :)

sehsarah commented 7 years ago

Note, realised this patch needs to be extended to ensure display: none on load too.

For now (in a rush) I've used this patch + the callback config as:

callback: function () {
    $(this).css('display', 'none');
}

Will come back to this. Still mergeable tho IMO