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

currentSlide undefined on mount with carousel later snapping into place #389

Open
JohnENoonan opened this issue Aug 13, 2024 · 0 comments
Open

Comments

@JohnENoonan
Copy link

Describe the bug
I have a carousel which is created from a list of objects (which only stores 2 strings) stored via pinia state management. When loading the page the carousel is in-between slides and after about a second or so it snaps to the correct modelValue. I've tried setting the modelValue to a static integer but the carousel still initializes in-between slides and snaps back.

When printing onMount the modelValue is set correctly but the currentSlide is undefined. Additionally I've confirmed my pinia objects are correct and non-null.

Thanks for any help 😄!
To Reproduce

<Carousel
	:itemsToShow="3"
	:wrapAround="true"
	:transition="500"
	:modelValue="piniaStore.initialSlide"
	ref="myCarousel"
	@slide-start="handleSlide"
>
	<Slide v-for="(option, index) in piniaStore.options" :key="option">
            <div class="carousel__item">
	            <h1 > {{ option.name }}  </h1>
            </div>
	</Slide>
</Carousel>
.carousel__slide {
	padding: 5;
}
.carousel__viewport {
	perspective: 2000px;
}
.carousel__track {
	transform-style: preserve-3d;
}
.carousel__slide--sliding {
	transition: 0.5s;
}
.carousel__slide {
	opacity: 0.9;
	transform: rotateY(-20deg) scale(var(--filter-other-scale));
}
.carousel__slide--active ~ .carousel__slide {
	transform: rotateY(20deg) scale(var(--filter-other-scale));
}
.carousel__slide--prev {
	opacity: var(--filter-other-opacity);
	transform: rotateY(-10deg) scale(var(--filter-other-scale));
}
.carousel__slide.carousel__slide--next {
	opacity: var(--filter-other-opacity);
	transform: rotateY(10deg) scale(var(--filter-other-scale));
}
.carousel__slide--active {
	opacity: 1;
	transform: rotateY(0) scale(1);
}
// pinia values on mount for example
// piniaStore.options = [{name: "option 1", date: "date 1"}, {name: "option 2", date: "date 2"}, etc.];
// piniaStore.initialSlide = 0;    

Expected behavior
The carousel will be initialized with the first slide being the one set as modelValue and currentSlide will be set to be equal to modelValue

Desktop (please complete the following information):

  • OS: Windows
  • Browser: chrome
  • Version: 127.0.6533.100
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

1 participant