codrops / ThumbnailGridExpandingPreview

A tutorial on how to create a thumbnail grid with an expanding image preview similar to the effect seen on Google Images.
360 stars 143 forks source link

hidePreview() hides expanded preview on scrolling (iphone) #17

Open coderbit-net opened 9 years ago

coderbit-net commented 9 years ago

Hi, first of all thanks for a grate js ))

I have an issue on iphone. If I click on a thumb, it opens an "expander", but as soon as I start to scroll, expanded block hides automatically. Trying to debug, I figured out that the reason is inside of initEvents(), somehow it detects iphones scrolling as window reaizing. Commenting out //hidePreview(); solves the problem on iphone but makes crap to desktop resizing. Is there a way to separate this to triggers?

Best regards.

coderbit-net commented 9 years ago

Hi again, so, i figured out that "expanded" block hides automatically only if the window is on its top. at this moment iOS safari browsers top bar (where you input url) transforms from big to small. After this top line gets small all next expanded blocks are scrolled as usuall, without closing automatically.

amichel86 commented 9 years ago

Hi Alex, thanks for your answer I commented out line #298 and it seems like the problem is solved. I am using Firefox responsive view and the original script was closing the expanded preview when the window width was at a certain resolution.

YuccaV2 commented 2 years ago

Very old post but many mobile browsers hide, show or resize their menu bar when scrolling up or down, which effectively resizes the window. So I solve this by catching the width of the window, on initEvents function : `var cachedWidth = $(window).width(); $window.on( 'debouncedresize', function() {

        var newWidth = $(window).width();
                if(newWidth !== cachedWidth){
                    //DO RESIZE HERE
                    cachedWidth = newWidth;
                    scrollExtra = 0;
                    previewPos = -1;
                    saveItemInfo();
                    getWinSize();
                    var preview = $.data( this, 'preview' );
                    if( typeof preview != 'undefined' ) {
                        hidePreview();
                    }
                }

    } );`