-
Notifications
You must be signed in to change notification settings - Fork 16
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
Consider Adding "Active" Class Identifier to Current Card #57
Comments
Thinking about this more, may not be possible since it's SSR'ed? |
I was actually thinking about this this morning! Yeah, we can't know that at SSG time since it's dependent on the viewport width. It could be something that gets added after client side mount though. I was also thinking that a more powerful way to do this would be via scoped slots. Like: ssr-carousel
template(#default='{ active }')
slide(
v-for='slide, index in slides'
:key='slide.id'
:active='active.contains(index)') The scoped slot We could also do a sugar prop that adds a CSS class like you were proposing, like when you don't need to know know it JS, just need to add some simple styling: ssr-carousel(add-active-classes)
slide(v-for='slide, index in slides' :key='slide.id') |
For this case, I believe active is only the case on mobile (and mainly touchscreens) when there's only 1 card showing. I think I've seen on other carousels that the "arrows" will just increment the slider by 1 index each time rather than paginate them. In this case active could also make sense. However, in cases where we are paginating and arrows shift by 2 or 3 at a time, I don't think active makes sense and we'd just set it to the first in that set? or maybe there's a mix of paginate and the arrows increment active by one? |
Yeah maybe this, more explicit API is better ssr-carousel
template(#default='{ featuredIndex }')
slide(
v-for='slide, index in slides'
:key='slide.id'
:class='{ active: featuredIndex == index }') Where
And then, with the sugar API: ssr-carousel(add-featured-class)
slide(v-for='slide, index in slides' :key='slide.id') This would add a Thoughts? |
+1 for this last explicit API and for the sugar API. Other slot prop ideas: |
With #62 I've added an |
I had a similar request, to add some additional styling to the centered slide and got it working using the tween:start event. Not that pretty though:
|
Had a request that's possible to add classes with existing carousel infrastructure, but may be worth adding an active class identifier to cards. Feels like a common standard among other carousels.
The text was updated successfully, but these errors were encountered: