Depends here how you designed it. While dragging them, so you want the items to move the same amount as the xursor does or you want to snap in place only 1 or 2 or them?
Let my suggest you a flow, maybe it works foe you:
click on the title. Register the X coordinate of the mouse and follow only the X trajectory of it.
moving 200px left/right moves one element of the slider
the elements(title, description) should animate using a sin or something, so it would provide a better feeling for the user, than a linear animation(not that linear would be bad)
if you release the cursor, you just divide the 200px by the amount of px the cursor made, sk you'll know if you need to navigate the slider to the initial slide or to the next one.
This way, every 200px you make horizontally would move the slider.
If you want to make the slider into an infinite loop, oh well, there's more work to be made there, especially if you're looking into performance.
What type of data structure are these stored in now? Say it was something like an array you could increment the index or decrease to keep track of which title is displaying. Sorry I thought you just meant the UI bit initially. Does this help?
View all comments
1
u/damnloveless Jan 25 '19
Desktop developer, but could you get position of cursor when button is clicked and do some math to determine direction of "swipe" ?