예제 #1
0
        private IEnumerator <object> HandleDragTask(VelocityMeter velocityMeter, float mouseProjectedPosition, DragGesture dragGesture)
        {
            if (!CanScroll || !ScrollWhenContentFits && MaxScrollPosition == 0 || ScrollBySlider)
            {
                yield break;
            }
            // Do not block scrollview on refresh gesture
            IsBeingRefreshed = false;
            IsDragging       = true;
            float realScrollPosition = ScrollPosition;

            wheelScrollState = WheelScrollState.Stop;
            while (dragGesture.IsChanging())
            {
                var newMouseProjectedPosition = ProjectToScrollAxisWithFrameRotation(Input.MousePosition);
                realScrollPosition += mouseProjectedPosition - newMouseProjectedPosition;
                // Round scrolling position to prevent blurring
                ScrollPosition         = ClampScrollPositionWithinBounceZone(realScrollPosition).Round();
                mouseProjectedPosition = newMouseProjectedPosition;
                velocityMeter.AddSample(realScrollPosition);
                yield return(null);
            }
            StartScrolling(InertialScrollingTask(velocityMeter.CalcVelocity()));
            IsDragging = false;
        }
예제 #2
0
 private IEnumerator <object> MainTask()
 {
     if (firstUpdate)
     {
         if (CenterWhenContentFits && ContentFits)
         {
             ScrollPosition = MinScrollPosition;
         }
         firstUpdate = false;
     }
     while (true)
     {
         if (dragGesture.WasBegan())
         {
             StopScrolling();
         }
         else if (dragGesture.WasRecognized())
         {
             var velocityMeter = new VelocityMeter();
             velocityMeter.AddSample(ScrollPosition);
             yield return(HandleDragTask(velocityMeter, ProjectToScrollAxisWithFrameRotation(dragGesture.MousePressPosition), dragGesture));
         }
         else if (!dragGesture.IsRecognizing())
         {
             Bounce();
         }
         yield return(null);
     }
 }