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

Loading issues related to <picture> elements? #1305

Open
spookiyu opened this issue Oct 10, 2024 · 4 comments
Open

Loading issues related to <picture> elements? #1305

spookiyu opened this issue Oct 10, 2024 · 4 comments

Comments

@spookiyu
Copy link

spookiyu commented Oct 10, 2024

My slider loads just fine at first, but from the second load (whether you go to another page and come back, refresh, etc.) you get an eternal loading symbol.

The really weird thing is that you can fix it by resizing the page? There's a breakpoint at 600px wide where the <picture> selects a different image source, and if you resize the window past that point, it fixes the slider completely. It seems the bxSlider isn't adding the necessary tags to my slider div until that resize (see the images below).

I restructured my site some time ago to use these <picture> elements with the breakpoints; I believe it didn't break until very recently, but I could be wrong.

Before resizing:
image

After resizing:
image

@vyvrhel
Copy link

vyvrhel commented Oct 11, 2024

In Firefox (since version 131.0), when bxSlider contains an <img> inside a <picture> element, the code responsible for the callback after image preload fails. The load/error events are not dispatched, and this.complete returns false.

selector.find('img:not([src=""]), iframe').each(function() {
  $(this).one('load error', function() {
    if (++count === total) { callback(); }
  }).each(function() {
    if (this.complete || this.src == '') { $(this).trigger('load'); }
  });
});

@spookiyu
Copy link
Author

Aha, thank you so much for the explanation! Sorry I'm a huge amateur, but is this code block a fix? I tried copypasting it and changing selector to $(.slider), and it doesn't seem to have done anything.

@vyvrhel
Copy link

vyvrhel commented Oct 14, 2024

Aha, thank you so much for the explanation! Sorry I'm a huge amateur, but is this code block a fix? I tried copypasting it and changing selector to $(.slider), and it doesn't seem to have done anything.

I'm not offering a solution to the problem; I just wanted to clarify what the issue is and in which part of the library's code it occurs, as I'm dealing with it too.

Maybe it's not even a problem with bxSlider, but with Firefox—I don't know.

@Webzeugmacher
Copy link

Webzeugmacher commented Oct 22, 2024

Firefox now seems to set img.complete on the next frame.
Temporary Bugfix that works for us, is to use setTimeout or requestAnimationFrame to delay the complete-Test

}).each(function() {
  setTimeout(() => {
    if (this.complete || this.src == '') { $(this).trigger('load'); }
  }, 0);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants