Example #1
0
        public override float applyBoundaryConditions(ScrollMetrics position, float value)
        {
            D.assert(() => {
                if (value == position.pixels)
                {
                    throw new UIWidgetsError(new List <DiagnosticsNode>()
                    {
                        new ErrorSummary($"{GetType()}.applyBoundaryConditions() was called redundantly."),
                        new ErrorDescription($"The proposed new position, {value}, is exactly equal to the current position of the " +
                                             $"given {position.GetType()}, {position.pixels}.\n" +
                                             "The applyBoundaryConditions method should only be called when the value is " +
                                             "going to actually change the pixels, otherwise it is redundant."),
                        new DiagnosticsProperty <ScrollPhysics>("The physics object in question was", this, style: DiagnosticsTreeStyle.errorProperty),
                        new DiagnosticsProperty <ScrollMetrics>("The position object in question was", position, style: DiagnosticsTreeStyle.errorProperty)
                    });
                }

                return(true);
            });
            if (value < position.pixels && position.pixels <= position.minScrollExtent)
            {
                return(value - position.pixels);
            }

            if (position.maxScrollExtent <= position.pixels && position.pixels < value)
            {
                return(value - position.pixels);
            }

            if (value < position.minScrollExtent && position.minScrollExtent < position.pixels)
            {
                return(value - position.minScrollExtent);
            }

            if (position.pixels < position.maxScrollExtent && position.maxScrollExtent < value)
            {
                return(value - position.maxScrollExtent);
            }

            return(0.0f);
        }
Example #2
0
        public override double applyBoundaryConditions(ScrollMetrics position, double value)
        {
            D.assert(() => {
                if (value == position.pixels)
                {
                    throw new UIWidgetsError(
                        $"{this.GetType()}.applyBoundaryConditions() was called redundantly.\n" +
                        $"The proposed new position, {value}, is exactly equal to the current position of the " +
                        $"given {position.GetType()}, {position.pixels}.\n" +
                        "The applyBoundaryConditions method should only be called when the value is " +
                        "going to actually change the pixels, otherwise it is redundant.\n" +
                        "The physics object in question was:\n" + $"  {this}\n" +
                        "The position object in question was:\n" + $"  {position}\n");
                }

                return(true);
            });
            if (value < position.pixels && position.pixels <= position.minScrollExtent)
            {
                return(value - position.pixels);
            }

            if (position.maxScrollExtent <= position.pixels && position.pixels < value)
            {
                return(value - position.pixels);
            }

            if (value < position.minScrollExtent && position.minScrollExtent < position.pixels)
            {
                return(value - position.minScrollExtent);
            }

            if (position.pixels < position.maxScrollExtent && position.maxScrollExtent < value)
            {
                return(value - position.maxScrollExtent);
            }

            return(0.0);
        }