protected virtual void StartInertialScroll(Vector2 swipeVelocity)
        {
            if (thisScrollerAxis == ScrollerAxis.Horizontal)
            {
                IInertialScrollProcess process = thisUISystemProcessFactory.CreateInertialScrollProcess(
                    swipeVelocity[0],
                    1f,
                    this,
                    thisScrollerElement,
                    0,
                    thisInertiaDecay
                    );
                process.Run();
            }
            else if (thisScrollerAxis == ScrollerAxis.Vertical)
            {
                IInertialScrollProcess process = thisUISystemProcessFactory.CreateInertialScrollProcess(
                    swipeVelocity[1],
                    1f,
                    this,
                    thisScrollerElement,
                    1,
                    thisInertiaDecay
                    );
                process.Run();
            }
            else
            {
                float sine;
                float cosine;
                DKUtility.Calculator.CalcSineAndCosine(swipeVelocity, out sine, out cosine);
                if (sine < 0f)
                {
                    sine *= -1f;
                }
                if (cosine < 0f)
                {
                    cosine *= -1f;
                }

                IInertialScrollProcess horizontalProcess = thisUISystemProcessFactory.CreateInertialScrollProcess(
                    swipeVelocity[0],
                    cosine,
                    this,
                    thisScrollerElement,
                    0,
                    thisInertiaDecay
                    );
                horizontalProcess.Run();
                IInertialScrollProcess verticalProcess = thisUISystemProcessFactory.CreateInertialScrollProcess(
                    swipeVelocity[1],
                    sine,
                    this,
                    thisScrollerElement,
                    1,
                    thisInertiaDecay
                    );
                verticalProcess.Run();
            }
        }
        protected void StartInertialScrollOnAxis(
            Vector2 velocity,
            int axis
            )
        {
            float decelerationOnAxis = CalcDecelerationOnAxis(
                velocity,
                axis
                );
            IInertialScrollProcess process = thisUISystemProcessFactory.CreateInertialScrollProcess(
                velocity[axis],
                decelerationOnAxis,
                this,
                thisScrollerElement,
                axis,
                thisInertiaDecay
                );

            process.Run();
        }
Esempio n. 3
0
        protected virtual void StartInertialScroll(Vector2 swipeVelocity)
        {
            ResetDrag();

            if (InitialVelocityIsOverThreshold(swipeVelocity))
            {
                DisableScrollInputRecursively(this);
            }

            if (thisScrollerAxis == ScrollerAxis.Horizontal)
            {
                IInertialScrollProcess process = thisProcessFactory.CreateInertialScrollProcess(swipeVelocity[0], 1f, this, thisScrollerElement, 0);
                process.Run();
            }
            else if (thisScrollerAxis == ScrollerAxis.Vertical)
            {
                IInertialScrollProcess process = thisProcessFactory.CreateInertialScrollProcess(swipeVelocity[1], 1f, this, thisScrollerElement, 1);
                process.Run();
            }
            else
            {
                float sine;
                float cosine;
                DKUtility.Calculator.CalcSineAndCosine(swipeVelocity, out sine, out cosine);
                if (sine < 0f)
                {
                    sine *= -1f;
                }
                if (cosine < 0f)
                {
                    cosine *= -1f;
                }

                IInertialScrollProcess horizontalProcess = thisProcessFactory.CreateInertialScrollProcess(swipeVelocity[0], cosine, this, thisScrollerElement, 0);
                horizontalProcess.Run();
                IInertialScrollProcess verticalProcess = thisProcessFactory.CreateInertialScrollProcess(swipeVelocity[1], sine, this, thisScrollerElement, 1);
                verticalProcess.Run();
            }
        }