onDraging slides doesn't return index of new visible element.
See original GitHub issueDescribe the feature you’d like: Currently, there is no good way of selecting a new slide on when you finish dragging on a tablet or phone. Add some property which will control which slide is visible now. Because all workarounds have a lot of bugs.
Suggested implementation: When on drag is finished and only when a new screen is shown return to a user index of a new visible slide
Describe alternatives you’ve considered: this code is working but it is kinda clunky
onTransitionEnd={ () => {
if (!isOnDesktop) {
const visible = document.querySelector('.videoSlider .carousel__slide--visible .video');
console.log(visible);
items.forEach(({ id: vId }, i) => {
if (vId === visible) {
console.log(i, 'i', vId);
handleChangeVideo(i);
}
});
console.log(items, visible.id, 'visible');
}
} }
Teachability, Documentation, Adoption, Migration Strategy:
onDragSlideEnd
return an index of a new slide or return -1 if the slide has not changed.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Detecting value of selected Draggable Item - GSAP - GreenSock
For some reason, I can't figure out how to access the id of the selected element in order to use the value in...
Read more >Problem with slide show in Javascript. Slide index does't work
I try to create a slideshow with an active dot while a slide is visible. Unfortunately when I use slideIndex-1 or slideIndex+1 the...
Read more >ASP.NET Core Blazor event handling - Microsoft Learn
Learn about Blazor's event handling features, including event argument types, event callbacks, and managing default browser events.
Read more >5 Loading Web pages — HTML5 - W3C
When a Window object is indexed to retrieve an indexed property index , the value returned must be the WindowProxy object of the...
Read more >Gestures and Touch Events | CodePath Android Cliffnotes
setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // Interpret MotionEvent data // Handle touch here ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@vignitres I believe this can be done with an HOC inside the CarouselProvider. Add a callback to the resulting HOC and it will get passed to your wrapped component. The wrapped component will have access to the props that the HOC provides your component.
then the component rendering would have something like this,
Yes! I managed to do that a few days ago. I guess I’m just used to dealing with this using events, but for some odd reason, this solution just feels right.
Thanks anyways!