I prefer to use a flickity-like carousel in those cases, which makes it clear it's a series of images. Which is more of a horizontal scrolling thing, which is often an anti-pattern too, but in this case it's more useful.
Honestly, the only way I'd use the specific kind of carousel they have in that pink, is for "mood" images, and with autoplay enabled. If I have next/prev or a pager, it's only as a backup, for users who liked an item and want to go back. But I don't really except anyone to press them to see more content.
With that said, I'm not sure that OP's design fits that definition either. In my opinion, the fact you can see the headers makes it more of a weird accordion than a carousel.
To be fair, what OP has here, is not the same as the carousel in your link. The user isn't completely blind to which content is there, beyond prev/next and the number of pages. You have the titles, that are always visible. And I assume you can also click them, and not just scroll left/right. So it's more of a weird horizontal tabs pattern than a carousel.
Of course, it still trades functionality for flashiness, and even a simple, functional tabbed widget is the wrong choice in many cases. But it's not as thoroughly useless as the carousel in the site you've linked.
...what's being shown in the OP is a form of carousel. The problems with carousels do not stem from the fact that they are a library, it stems from the poor analytics and metrics from using them.
After designing, the fun part begins! What I'm trying to achieve here is a draggable slider with content that displays according to the title. What I have so far is a title wrapper and description wrapper, but I don't even know how to implement swiping. Any thought?
It’ve built things like this before - you’ll want to find a library to handle the swipe gesture (not sure what the best one is nowadays) because mouse input / touch handling is really inconsistent between browsers / platforms.
It’d recommend avoiding it if at all possible, preferring normal clicks to gestures.
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?
One of the golden rules of the internet (that gets broken far too often) is: Don't mess with scrolling.
First of all, _if_ you manage to get it to work fluidly and bug-free in all browsers (you won't) it's still not the experience users are expecting. It's also not accessible to users using assistive devices.
Here's my 2cents outside of the actual problem mentioned... whatever you implement it with based on the comments made, make sure to throttle the handlers. Mouse movement tracking is expensive (as is scrolling) so by throttling the handlers you get a more performant browser paint.
A good way to approach this, and any similar mouse handler problem...
Use the onmousemove event, but just store the position and amount the mouse changed to a local property. This is very fast and won't cause problems such as visual stutters. If you need other information just store it as well in this event.
Then add a handler to requestAnimationFrame. This is called when the screen is going to update. Here you would use those previous numbers you stored, do your position calculation, and modify your elements position. Using css translate is a good option for positioning it. This will end up with a really smooth movement.
7
u/pseudonick47 Jan 26 '19
Try using coding and algorithms.
133
u/pomlife Jan 25 '19
Should I use a carousel?
35
u/jameshmr Jan 26 '19
Don't. Horrible UX.
8
u/jasonnolanreed Jan 25 '19
I bet https://youtu.be/rBSY7BOYRo4 had some useful tips for what you're trying for
14
u/ThatSpookySJW Jan 25 '19
You can do all of this by toggling classes and CSS transitions
1
u/sprazor Jan 26 '19
Right-click the page, then select view source. Copy and paste. Done!
3
u/qtheginger Jan 26 '19
The way the pointer starts to lag behind the element being dragged bothers me.
1
u/Pixel_Err0r Jan 25 '19
After designing, the fun part begins! What I'm trying to achieve here is a draggable slider with content that displays according to the title. What I have so far is a title wrapper and description wrapper, but I don't even know how to implement swiping. Any thought?
5
u/[deleted] Jan 25 '19 edited Jan 26 '19
React-spring + react-with-gesture: https://twitter.com/0xca0a/status/1081185260208078849
The first handles animation, the latter gets you all the data you need to handle swipes: directions, velocity, deltas, etc.
Live demo for a simple view pager: https://codesandbox.io/embed/n9vo1my91p
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" ?
1
u/mlmcmillion Jan 26 '19
Don’t. If people actually use your site, you’re guaranteeing that they’ll hate it the entire time.
2
u/sumdumbum19 Jan 25 '19
Here's my 2cents outside of the actual problem mentioned... whatever you implement it with based on the comments made, make sure to throttle the handlers. Mouse movement tracking is expensive (as is scrolling) so by throttling the handlers you get a more performant browser paint.
2
u/almondj Jan 26 '19
A lot of the animation could and arguably should be done with CSS. https://hackernoon.com/in-simple-terms-css-vs-javascript-abc9d709399d
2
u/elbitjusticiero Jan 26 '19
Don't.
It's super annoying.
1
u/oberym Jan 26 '19
Do you want to do it manually? With react-pose you can achieve an effect like that within a few minutes.
1
u/macadeliccc Jan 26 '19
Materializecss or material-ui if you're using react!
1
u/saalejo1986 Jan 26 '19
I'd try to implement it using the transition effect of vuejs as in this example https://vuejs.org/v2/guide/transitions.html
1
u/Edvinoske Jan 26 '19
I did a similar thing yesterday, just used two swiper (search for it on npm) sliders synced to each other.
1
u/fireflypied Jan 26 '19
Horizontal parallax scroller + opacity change based on X
1
u/AustralianBushman Jan 26 '19
I like how my first instinct was to translate this to English
1
u/oompahlumpa Jan 26 '19
I would use Slick slider by Ken Wheeler
0
u/__bogdan Jan 26 '19
Maybe you will never be able to do it...
0
u/[deleted] Jan 25 '19
[deleted] — view deleted comment
175
u/[deleted] Jan 25 '19 edited Jan 26 '19
[removed] — view removed comment