Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product gallery jumps while loading #32315

Closed
5 tasks
ihor-sviziev opened this issue Mar 1, 2021 · 13 comments
Closed
5 tasks

Product gallery jumps while loading #32315

ihor-sviziev opened this issue Mar 1, 2021 · 13 comments
Assignees
Labels
Issue: needs update Additional information is require, waiting for response Issue: ready for confirmation Priority: P3 May be fixed according to the position in the backlog. Progress: done

Comments

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Mar 1, 2021

It seems like after #27871 we have a bit jumpy gallery again. My investigation shown that it's happening because of not hiding the thumbnails below the big image.

/CC @krzksz

Preconditions (*)

Steps to reproduce (*)

  1. Open frontend in chrome, open developer tools
  2. In the "source tab" set a breakpoint on the following line:
    $fotoramaStage.css('position', 'absolute');
  3. refresh the page
  4. When the script will stop on breakpoint switch to the elements tab and find the .fotorama-item item

Expected result (*)

  1. There should be no jumps during gallery load

Actual result (*)

  1. fotorama-items eats some space that causes not expected layout shifts:
    Dev tools:
    image
    Desktop:
    image
    Mobile:
    image
Echo.Fit.Compression.Short.-.Google.Chrome.2021-03-01.16-04-55.mp4

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Mar 1, 2021

Hi @ihor-sviziev. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@ihor-sviziev
Copy link
Contributor Author

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @ihor-sviziev. Thank you for your request. I'm working on Magento instance for you.

@ihor-sviziev ihor-sviziev changed the title Gallery jumps Product gallery jumps while loading Mar 1, 2021
@sivaschenko sivaschenko added the Priority: P3 May be fixed according to the position in the backlog. label Mar 2, 2021
@Quazz
Copy link

Quazz commented Apr 8, 2021

Personally I've replaced the function with

        initGallery: function () {
            var breakpoints = {},
                settings = this.settings,
                config = this.config,
                tpl = template(galleryTpl, {
                    next: $t('Next'),
                    previous: $t('Previous')
                }),
                mainImageIndex,
                $element = settings.$element,
                $fotoramaElement;

            if (settings.breakpoints) {
                _.each(_.values(settings.breakpoints), function (breakpoint) {
                    var conditions;

                    _.each(_.pairs(breakpoint.conditions), function (pair) {
                        conditions = conditions ? conditions + ' and (' + pair[0] + ': ' + pair[1] + ')' :
                        '(' + pair[0] + ': ' + pair[1] + ')';
                    });
                    breakpoints[conditions] = breakpoint.options;
                });
                settings.breakpoints = breakpoints;
            }

            _.extend(config, config.options,
                {
                    options: undefined,
                    click: false,
                    breakpoints: null
                }
            );
            settings.currentConfig = config;

            $element
                .css('min-height', settings.$element.height())
                .append(tpl);

            $fotoramaElement = $element.find('[data-gallery-role="gallery"]');

            $fotoramaElement.fotorama(config);
            $fotoramaElement.hide();
            $element.find('.gallery-placeholder__image').remove();
            $element
                .removeClass('_block-content-loading')
                .css('min-height', '');
            $fotoramaElement.show();

            settings.$elementF = $fotoramaElement;
            settings.fotoramaApi = $fotoramaElement.data('fotorama');

            $.extend(true, config, this.startConfig);

            mainImageIndex = getMainImageIndex(config.data);

            if (mainImageIndex) {
                this.settings.fotoramaApi.show({
                    index: mainImageIndex,
                    time: 0
                });
            }
        }

I found the fotoramaStage troublesome like you did and the f:load function seems unreliable (causing jumps as well)

Since the slowest part is loading the gallery, hiding the element, removing placeholder, then showing the element seemed to be the most reliable answer. I tried other variations, trying to make use of the fotorama f:load event, but it never seemed to produce the desired results in a reliable fashion.

@ihor-sviziev
Copy link
Contributor Author

@Quazz, your solution will probably cause gallery blinking and potentially add Layout Shift, making worse Google Pagespeed Results.

@ihor-sviziev
Copy link
Contributor Author

ihor-sviziev commented Apr 9, 2021 via email

@engcom-Dash engcom-Dash self-assigned this Mar 11, 2024
Copy link

m2-assistant bot commented Mar 11, 2024

Hi @engcom-Dash. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

    1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    1. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
    1. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

@engcom-Dash
Copy link

@magento give me 2.4-develop instance

Copy link

Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you.

Copy link

@engcom-Dash
Copy link

Hi @ihor-sviziev

Thanks for reporting and collaboration.

We have verified the issue in magento 2.4 dev instance but we are not seeing the lines $fotoramaStage.css('position', 'absolute'); in line 307 on source tab.

Can you please share the detailed steps to reproduce inorder for us to test the issue.

Please refer the attached screenshots and let us know if we missed anything.
Screenshot 2024-03-20 at 6 42 42 PM

@engcom-Dash engcom-Dash added the Issue: needs update Additional information is require, waiting for response label Mar 20, 2024
@ihor-sviziev
Copy link
Contributor Author

These changes were already merged in another pull request #33265 (comment)

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: needs update Additional information is require, waiting for response Issue: ready for confirmation Priority: P3 May be fixed according to the position in the backlog. Progress: done
Projects
Development

Successfully merging a pull request may close this issue.

4 participants