dnd-kit icon indicating copy to clipboard operation
dnd-kit copied to clipboard

AutoScroll option to scroll only horizontally/vertically

Open mieszkosabo opened this issue 3 years ago • 1 comments

Hi, I wanted to make container auto-scroll only on horizontal axis. I managed to do so with: <DndContext autoScroll={{ threshold: { x: 0.2, y: 0 } }} > I used 0.2 as it is a default value.

I was wondering if there was a cleaner way to achieve this and if not, would you accept a PR with a new AutoScrollOption that could enforce this behaviour.

mieszkosabo avatar Feb 01 '22 15:02 mieszkosabo

There is a restrictToHorizontalAxis modifier which can be imported from @dnd-kit/modifiers

import { restrictToHorizontalAxis } from "@dnd-kit/modifiers";
<DndContext modifiers={[restrictToHorizontalAxis]} >

freott avatar Sep 23 '22 08:09 freott

The problem with using the restrictToHorizontalAxis modifier is that it also restricts other elements like the dragOverlay.

CronJorian avatar Oct 04 '22 07:10 CronJorian