Transition?ParseValue(CSSValueList values)
        {
            CSSPrimitiveValue <Time> delay    = null;
            CSSPrimitiveValue <Time> duration = null;
            CSSTimingValue           function = null;
            String property = null;

            for (var i = 0; i < values.Length; i++)
            {
                if (function == null && (function = values[i].ToTimingFunction()) != null)
                {
                    continue;
                }

                if (property == null && values[i] is CSSIdentifierValue)
                {
                    property = ((CSSIdentifierValue)values[i]).Value;
                    continue;
                }

                if (values[i] is CSSPrimitiveValue <Time> )
                {
                    var time = (CSSPrimitiveValue <Time>)values[i];

                    if (duration == null)
                    {
                        duration = time;
                        continue;
                    }
                    else if (delay == null)
                    {
                        delay = time;
                        continue;
                    }
                }

                return(null);
            }

            return(new Transition
            {
                Delay = delay != null ? delay.Value : Time.Zero,
                Duration = duration != null ? duration.Value : Time.Zero,
                Timing = function ?? CSSTimingValue.Ease,
                Property = property ?? "all"
            });
        }
Example #2
0
        Animation?ParseValue(CSSValueList values)
        {
            CSSPrimitiveValue <Time>   delay          = null;
            CSSPrimitiveValue <Time>   duration       = null;
            CSSPrimitiveValue <Number> iterationCount = null;
            CSSTimingValue             function       = null;
            AnimationFillMode?         fillMode       = null;
            AnimationDirection?        direction      = null;
            String name = null;

            for (var i = 0; i < values.Length; i++)
            {
                if (function == null && (function = values[i].ToTimingFunction()) != null)
                {
                    continue;
                }

                if (values[i] is CSSIdentifierValue)
                {
                    if (name == null)
                    {
                        name = ((CSSIdentifierValue)values[i]).Value;
                        continue;
                    }

                    if (!fillMode.HasValue && (fillMode = values[i].ToFillMode()).HasValue)
                    {
                        continue;
                    }

                    if (!direction.HasValue && (direction = values[i].ToDirection()).HasValue)
                    {
                        continue;
                    }
                }

                if (values[i] is CSSPrimitiveValue <Time> )
                {
                    var time = (CSSPrimitiveValue <Time>)values[i];

                    if (duration == null)
                    {
                        duration = time;
                        continue;
                    }
                    else if (delay == null)
                    {
                        delay = time;
                        continue;
                    }
                }

                if (iterationCount == null && values[i] is CSSPrimitiveValue <Number> )
                {
                    iterationCount = (CSSPrimitiveValue <Number>)values[i];
                    continue;
                }

                return(null);
            }

            return(new Animation
            {
                Delay = delay != null ? delay.Value : Time.Zero,
                Duration = duration != null ? duration.Value : Time.Zero,
                Timing = function ?? CSSTimingValue.Ease,
                Name = name ?? "none",
                IterationCount = iterationCount != null ? iterationCount.Value.Value : 1f,
                FillMode = fillMode.HasValue ? fillMode.Value : AnimationFillMode.None,
                Direction = direction.HasValue ? direction.Value : AnimationDirection.Normal
            });
        }