Open
Description
Clear and concise description of the problem
I am running a multi row (swiper) image gallery which is actionable and I am lazy loading the images with my custom logic. Because I need the performance I didn't want to relay on the swiper but unfortunately it attaches listeners anyway. Which makes it 100% unusable for my usecase. Currently I am patching the swiper to stop that behavior.
Suggested solution
diff --git a/shared/swiper-core.mjs b/shared/swiper-core.mjs
index 619c42a4ee03ac543db7869eb80aa7e782bccab2..06880c6f982f6d2d62dad27700a3ea13a5652a20 100644
--- a/shared/swiper-core.mjs
+++ b/shared/swiper-core.mjs
@@ -2860,9 +2860,9 @@ const events = (swiper, method) => {
}
// Images loader
- el[domMethod]('load', swiper.onLoad, {
- capture: true
- });
+ // el[domMethod]('load', swiper.onLoad, {
+ // capture: true
+ // });
};
function attachEvents() {
const swiper = this;
@@ -3614,11 +3614,11 @@ class Swiper {
if (params.breakpoints) {
swiper.setBreakpoint();
}
- [...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
- if (imageEl.complete) {
- processLazyPreloader(swiper, imageEl);
- }
- });
+ // [...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
+ // if (imageEl.complete) {
+ // processLazyPreloader(swiper, imageEl);
+ // }
+ // });
swiper.updateSize();
swiper.updateSlides();
swiper.updateProgress();
@@ -3786,19 +3786,19 @@ class Swiper {
// Attach events
swiper.attachEvents();
- const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
- if (swiper.isElement) {
- lazyElements.push(...swiper.hostEl.querySelectorAll('[loading="lazy"]'));
- }
- lazyElements.forEach(imageEl => {
- if (imageEl.complete) {
- processLazyPreloader(swiper, imageEl);
- } else {
- imageEl.addEventListener('load', e => {
- processLazyPreloader(swiper, e.target);
- });
- }
- });
+ // const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
+ // if (swiper.isElement) {
+ // lazyElements.push(...swiper.hostEl.querySelectorAll('[loading="lazy"]'));
+ // }
+ // lazyElements.forEach(imageEl => {
+ // if (imageEl.complete) {
+ // processLazyPreloader(swiper, imageEl);
+ // } else {
+ // imageEl.addEventListener('load', e => {
+ // processLazyPreloader(swiper, e.target);
+ // });
+ // }
+ // });
preload(swiper);
// Init Flag
We can add if( preloadEnabled ) props around this behavior
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Would you like to open a PR for this feature?
- I'm willing to open a PR