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

fix(lazy): only activate preloader-spin animation when slide is activ… #5203

Merged
merged 3 commits into from
Feb 1, 2022

Conversation

aynzad
Copy link
Contributor

@aynzad aynzad commented Nov 16, 2021

Related to the #5202

When Swiper with Lazy Images module is used, CPU usage is always high on the page even when there is no activity.

Solved by removing spinner animation from all non-activated lazy-preloader elements

@vltansky
Copy link
Collaborator

Solving #5202 issue?
What is the CPU usage after this fix?

@aynzad
Copy link
Contributor Author

aynzad commented Dec 29, 2021

Solving #5202 issue? What is the CPU usage after this fix?

mentioned on "Expected Behavior", something near 0.1%

@vltansky
Copy link
Collaborator

  1. Didn't get it, will this change close issue Preloader CSS animation on Lazy module causing heavy CPU usage #5202 ?
  2. I think animation should be applied to visible slides also, see
    https://swiperjs.com/swiper-api#lazy-loading

If you use slidesPerView: 'auto' or slidesPerView > 1, then you should also enable watchSlidesProgress and Swiper will load images in currently visible slides

https://codesandbox.io/s/swiper-lazy-load-images-forked-cp29n?file=/index.html

@aynzad
Copy link
Contributor Author

aynzad commented Jan 31, 2022

https://codesandbox.io/s/swiper-lazy-load-images-forked-cp29n?file=/index.html

‍1. Yes, will close this issue
2. Don't get it really, There should not be any animation for invisible slides in any condition.

@vltansky
Copy link
Collaborator

image

Only this slide is .swiper-active while others are .swiper-visible (when multiple slides are visible)

@aynzad
Copy link
Contributor Author

aynzad commented Jan 31, 2022

image

Only this slide is .swiper-active while others are .swiper-visible (when multiple slides are visible)

Oh I see. I made a change.

Thank you

@vltansky vltansky self-requested a review February 1, 2022 07:25
@nolimits4web nolimits4web merged commit b7d89ea into nolimits4web:master Feb 1, 2022
@vltansky
Copy link
Collaborator

vltansky commented Feb 1, 2022

@aynzad thanks for your contribution! Your changes released in v8 🎉

@aynzad
Copy link
Contributor Author

aynzad commented Feb 4, 2022

@aynzad thanks for your contribution! Your changes released in v8 🎉

I'm glad to help

@ybiquitous
Copy link

Hi. I notice that animation isn't working on the following official demo:
https://swiperjs.com/demos/370-lazy-load-images/core.html

Is it necessary to add an extra configuration about .swiper-visible?

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

Successfully merging this pull request may close these issues.

4 participants