nnattawat / flip

A lightweight jQuery plugin to make 3D card flipping animation
Other
624 stars 312 forks source link

Chrome V49 won't update changed img src with backface-visibility: hidden #80

Open mrtree1 opened 8 years ago

mrtree1 commented 8 years ago

We spotted that the latest V49 version of Chrome causes any changes to an src attribute with backface-visibility set to hidden not to render the new image (i.e. it shows it's originally set image src, even though the src is changes in the DOM). This is a change which only occurred in Chrome 49, and I'd argue it's a bug in the browser, but to fix it I have had to wrap the code which sets backface-visibility to only operate when the browser's not Chrome.

            var isChrome = !!window.chrome && !!window.chrome.webstore;
            if (!isChrome) {
                faces.find('*').css({
                    "backface-visibility": "hidden"
                });
            }

This code is clearly put in for good reason, so I've not sent this in as a pull request. Maybe the find should be something like :not(img), if it's needed for other elements only?

aaronberg commented 8 years ago

I ran into the same issue, but this fix didn't quite work. The solution that worked for me was to do make the backface visible like this:

$(element).css({"backface-visibility": "visible"});

Then attach a load event to the image element, which does this after the image has loaded:

$(element).css({"backface-visibility": "hidden"});

Then change the image src. Because the backface is visible during the load Chrome will redraw with the new image.

JemarJones commented 8 years ago

Can the issue please be reproduced in a jsfiddle perhaps?

himrocks commented 7 years ago

Same issue on chrome 55 too