# Viewport: Enable scrollOnDrag while dragging

**URL:** <https://forum.juce.com/t/viewport-enable-scrollondrag-while-dragging/19085>\
**Category:** General JUCE discussion\
**Created:** [September 13, 2016, 10:32pm UTC](https://forum.juce.com/t/viewport-enable-scrollondrag-while-dragging/19085 "2016-09-13T22:32:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Achder](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/achder/32/5897_2.png) [@Achder](https://forum.juce.com/u/Achder)\
**Post date:** [September 13, 2016, 10:32pm UTC](https://forum.juce.com/t/viewport-enable-scrollondrag-while-dragging/19085/1 "2016-09-13T22:32:13Z")

</div>

Hi!  
I am enabling the scrollOnDrag() of a viewport, while I’m in drag mode. I do this because I only want scrolling to be enabled, when I do a vertical scroll. So I calculate the angle of the drag in my mouse listener and when its vertically enough I enable scrollOnDrag of the viewport.

The problem is this doesn’t work, because the viewport creates a new DragToScrollListener when I enable scrollOnDrag(). When this happens the DragToScrollListener resets the “numTouches”. So when I keep dragging the listener thinks no touch is active and no scrolling happens.

What is the best way to fix this?
