lightcase icon indicating copy to clipboard operation
lightcase copied to clipboard

Autosize of images fails on Microsoft edge.

Open fabman opened this issue 9 years ago • 19 comments

Lightcase randomly fails to set the proper size of the image. For what I see it seems to get the height of the loading animation and leaves that size for the image when it finishes loading.

Also, if I trigger a browser resize jQuery(window).trigger('resize'); the image will refresh and fit properly.

A video and a image of what it seems to happen:

http://www.youtube.com/watch?v=fN5RqY4CbIY&hd=1

image

fabman avatar Jul 26 '16 09:07 fabman

Or in any case, where / how could I force the code $(window).trigger('resize');after it finish each next or previous event.

I tried including a triggerResize after _adjustDimensions but it won't work ( it hangs the browser )

image

fabman avatar Jul 26 '16 15:07 fabman

Did you consider to use one of the hook functions? http://cornel.bopp-art.com/lightcase/documentation/#hooks

On 26.07.2016, at 17:25, Fabian [email protected] wrote:

Or in any case, where / how could I run a $(window).trigger('resize');after it finish each next or previous event.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

cbopp-art avatar Jul 28 '16 17:07 cbopp-art

I did, I included the trigger resize on the onFinish hook function, but it doesn't work. But if I apply that trigger on the console it does work perfectly. It's pretty strange really.

Thanks!

fabman avatar Jul 28 '16 17:07 fabman

call instead: lightcase.resize();

On 28.07.2016, at 19:16, Fabian [email protected] wrote:

I did, I included the trigger resize on the onFinish hook function, but it doesn't work. But if I apply that trigger on the console it does work perfectly. It's pretty strange really.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

cbopp-art avatar Jul 28 '16 17:07 cbopp-art

image

Same problem:

image

fabman avatar Jul 28 '16 17:07 fabman

And this just happens in Internet explorer ( edge and 11 so far ). In Chrome, Firefox, Safari and Opera everything works perfectly.

fabman avatar Jul 28 '16 17:07 fabman

It seems that it doesn't sets properly the size of the container even when the size of the image is properly set.

image

fabman avatar Jul 28 '16 17:07 fabman

Strange! Could you may provide a link to something like a test page where it is possible to reproduce that issue?

cbopp-art avatar Jul 29 '16 03:07 cbopp-art

I'll setup a testing server and send you the link. Thanks for the help!

fabman avatar Jul 29 '16 08:07 fabman

I just emailed you the url user and password for testing purposes

fabman avatar Jul 29 '16 12:07 fabman

Thank you - I will have a look!

cbopp-art avatar Jul 31 '16 20:07 cbopp-art

Hi!, any luck with this?. I am working on this myself too, but I can't seem to solve it. :-(

fabman avatar Aug 02 '16 14:08 fabman

Not yet, but I will also take a second look on it.

cbopp-art avatar Aug 02 '16 15:08 cbopp-art

I hacked this as a temporary solution, it triggers a resize event half a second after if finish showing the next slide. There's an annoying flash but at least this hack gives me time to look for a proper solution.

image

fabman avatar Aug 02 '16 17:08 fabman

Ok, narrowing the problem:

I added a console log to this function: image

And it seems that the problem is that there's no "height" dimension when the function tries to set the height on the css. image

fabman avatar Aug 02 '16 19:08 fabman

For what I'm seeing it must be something related to the lag while loading each image, because if you watch all the slides and go back to the beginning the second pass won't fail. It seems the problem must be related with the code trying to get the dimensions of the image while it hasn't been fully loaded.

fabman avatar Aug 03 '16 09:08 fabman

Ok, I think I solved the problem. If I add a 100 miliseconds delay when showing the content I give time to the IE to add the img to the DOM and get the proper height.

image



    /**
     * Loads the new object
     *
     * @param   {object}    $object
     * @return  {void}
     */
    _loadObject: function ($object) {
        // Load the object
        switch (_self.objectData.type) {
        case 'inline':
            if ($(_self.objectData.url)) {
            _self._showContent($object);
            } else {
            _self.error();
            }
            break;
        case 'ajax':
            $.ajax(
            $.extend({}, _self.settings.ajax, {
                url: _self.objectData.url,
                type: _self.objectData.requestType,
                dataType: _self.objectData.requestDataType,
                data: _self.objectData.requestData,
                success: function (data, textStatus, jqXHR) {
                // Unserialize if data is transferred as json
                if (_self.objectData.requestDataType === 'json') {
                    _self.objectData.data = data;
                } else {
                    $object.html(data);
                }
                _self._showContent($object);
                },
                error: function (jqXHR, textStatus, errorThrown) {
                _self.error();
                }
            })                  
            );
            break;
        case 'flash':
            _self._showContent($object);
            break;
        case 'video':
            if (typeof($object.get(0).canPlayType) === 'function' || _self.objects.case.find('video').length === 0) {
            _self._showContent($object);
            } else {
            _self.error();
            }
            break;
        default:
            if (_self.objectData.url) {
            $object.load(function () {
    // ----------------------------------------------------------
                setTimeout(function(){ _self._showContent($object); }, 100);
    // ----------------------------------------------------------
            });
            $object.error(function () {
                _self.error();
            });
            } else {
            _self.error();
            }
            break;
        }
    },

fabman avatar Aug 03 '16 12:08 fabman

Still an issue? Maybe solced using the new version v2.4.0?!

cbopp-art avatar Apr 09 '17 22:04 cbopp-art

@fabman any updates here? is it still an issue with the latest version?

cbopp-art avatar Feb 27 '18 10:02 cbopp-art