1 Reply Latest reply on Aug 21, 2015 6:58 AM by lj9022

    How to make a container automatically scroll when a dragged component reaches the edge

    lj9022

      Hi,

       

      I have a VGroup with a Scroller that has a few child components, one of which is a List. When the List is too long, users only needs to use the scroll bar up or down to see all the rows in the List. Users are also allowed to drag and drop the rows in the List to rearrange the order. My question is, when the List is partially shown and one needs to drag a row to the bottom of the List that's currently not inside the view, is there anyway to trigger the scroll bar to move up or down when the dragged row reaches the edges of the VGroup?

       

      Thanks for the help.

       

      JL

        • 1. Re: How to make a container automatically scroll when a dragged component reaches the edge
          lj9022 Level 1

          In case anyone interested, I ended up writing a "dragExit" event handler as follows:


              private function onDragExit(event:DragEvent):void {

                if (myViewPort.verticalScrollPosition < event.localY) {

                  myViewPort.verticalScrollPosition += scrollDelta;

                } else {

                  myViewPort.verticalScrollPosition -= scrollDelta;

                  if (myViewPort.verticalScrollPosition < 0) {

                    myViewPort.verticalScrollPosition = 0;

                  }

                }

              }


          One needs to drag the row to rub against the edge, i.e. going across back and forth, to make the viewport scroll. The solution is not satisfactory to me but functionally does what users need.