3 Replies
      Latest reply on Feb 10, 2020 12:04 PM by Claude31
      Paolo O. Level 1 Level 1 (0 points)

        I have a table with rows that can be reordered via drag and drop.


        My issue is that when the drag starts to scroll the table, the scrolling movement is really too fast. The table reaches immediately the top or the bottom without the possibility to slow down. It is really frustrating.


        I do not understand where to intervene or what to override to customize this behavior. I don't see anything related to this kind of "automatic" scrolling that I can change. I am really clueless at this point.

        Thanks in advance for any hint or pointer to a relevant piece of documentation.




        • Re: Table drag reorder scrolls too fast
          Claude31 Level 8 Level 8 (8,115 points)

          You have normally defined


              func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {



          Did you try to add somesleep time (0.2 s) here ? You could adapt this depending you are reaching top or bottom.

          That's a bit brute force, but should work.


          Could also try to use decelerationRate, but never used it.

            • Re: Table drag reorder scrolls too fast
              Paolo O. Level 1 Level 1 (0 points)

              Thanks for your help Claude31,


              since I am on macOS Appkit, I am using a NSTableView and NSScrollView and decelerationRate is not available.


              I tried to add a sleep of 0.2s to:


              func tableView(_ tableView: NSTableView, validateDrop info: NSDraggingInfo, proposedRow row: Int, proposedDropOperation dropOperation: NSTableView.DropOperation) -> NSDragOperation


              and it kind of works. The scrolling is slower and a little bit choppy but definitely more usable than before!

              I am still curious about the "proper" way of doing it, but thanks a lot and kudos for the help!



                • Re: Table drag reorder scrolls too fast
                  Claude31 Level 8 Level 8 (8,115 points)

                  To avoid the choppy effect, you should select when you force this delay.


                  May be you could try to do this only when scrolls begins (detect contentOffset change).


                  See here for some details (that's for iOS, but there should be analog in MacOS)

                  h ttps://bluelemonbits.com/2018/12/30/reloading-inserting-dynamic-height-cells-and-keeping-scroll-position/



                  h ttps://medium.com/hyperoslo/how-scroll-views-work-on-macos-f809225adcd


                  Don't forget to close the threa when concluded.