Figma Support Forum

Interactions / On Drag : Add Drag Direction

I’m building a simple prototype where a carousel of images can be swiped left/right to go to the next/previous image. I’m using the On Drag interaction but the problem is that it only accounts for one direction.

Imagine you have a strip of 3 images (A, B and C) where each image has the same width as the screen. If B is in the center, I can only use the On Drag interaction to go to either to A or C. Because there’s only one direction I can use.

This could be resolve by adding a specific direction for the On Drag interaction. On Left drag go to A, on Right Drag go to C.

This is a very common pattern. Does anyone figure out if there’s a work-around for this?

Thanks!

Hi @ma2os, On drag trigger works in any direction. You can see some examples in this thread: How does the picture carousel realize the interactive effect of connecting the beginning and the end?

Help Center article:
https://help.figma.com/hc/en-us/articles/360040035834-Prototype-triggers#On_Drag

Ohhhh!!! I wasn’t aware you can add multiple ‘drags’ interactions to the same element. That’s exactly what I needed. Thanks!