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

bug in page transition #19

Open
PouryaNoufallah96 opened this issue Dec 22, 2022 · 7 comments
Open

bug in page transition #19

PouryaNoufallah96 opened this issue Dec 22, 2022 · 7 comments
Labels
bug Something isn't working upstream this bug is caused by an upstream bug

Comments

@PouryaNoufallah96
Copy link

hello. i have a swiper in my main page and I also have global page transition In nuxt.config file. when i switch to another page and come back to the page that have swiper , it does not work any more and slides will disapear

@cpreston321
Copy link
Owner

Can you give me a reproduction on stackblitz ? Please 🙏🏼

@cpreston321 cpreston321 added bug Something isn't working reproduction-needed Please provide reproduction. labels Dec 26, 2022
@PouryaNoufallah96
Copy link
Author

https://github.com/PouryaNoufallah96/nuxt3-swiper-sample

i think the problem is dir="rtl" for body tag and also page transition.
when you go to page 2 and then come back to page1 the slider not working correctly

@cpreston321 cpreston321 removed the reproduction-needed Please provide reproduction. label Dec 31, 2022
@cpreston321
Copy link
Owner

Hey @PouryaNoufallah96 !

Thanks for the reproduction link. I will look into this as I suspect it being an upstream bug either with nuxt SSR or within swiper itself. I will let you know what I find!

Thanks,
Christian

@PouryaNoufallah96
Copy link
Author

hey ! ok thank you so much

@cpreston321 cpreston321 added the upstream this bug is caused by an upstream bug label Jan 24, 2023
@SPH73
Copy link

SPH73 commented Mar 3, 2023

Hello, I have this same issue, I have used the Swiper component on 3 pages and all three have the same issue where my CSS is respected on page refresh but when transitioning from page to page the CSS is lost until the page is refreshed again. I only noticed this behaviour today. Prior to this, I had only used it on 1 page. After adding Swiper to the other pages, I noticed that I couldn't make the component respect my CSS.

@cpreston321
Copy link
Owner

cpreston321 commented Mar 3, 2023

Follow Up

/cc: @SPH73 @PouryaNoufallah96: This does seem to be upstream.

Repo Link for reference: https://stackblitz.com/edit/github-gyz8yc

Looking further into the issue it seems that the app,layout transition causes Swiper to bug out on the some event dom calculation state. Swiper will try to run javascript on load and do certain runtime checks to figure width, height etc. Since Nuxt isn't showing the proper sizing it's like swiper has no idea so it's calculations are way off causing the swiper to bug out.

I'm not for sure really what to do, I would want to say take it up with the Swiper Core team and do a follow up with the repo link provided. In this case it's very odd.

My thought is that Swiper doesn't have the proper SSR support for vue making it hard to know if this a listener on the dom level doing calculation based on what it sees within the browser.

@nasirDoe
Copy link

Worked!!
workaround

const isInitialized = ref(false)

onMounted(() => {
 // my transition page is 300, when TIMEOUT set to 300 is not work. so must larger than transition page
  const TIMEOUT = 500 
  
   setTimeout(() =>{
       isInitialized.value = true
   }, TIMEOUT)
})

<Swiper v-if="isInitialized"></Swiper>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream this bug is caused by an upstream bug
Projects
None yet
Development

No branches or pull requests

4 participants