Exemplo n.º 1
0
    public void SetupPropertyAnim <T>(SLayoutProperty <T> layoutProperty)
    {
        SAnimatedProperty <T> animatedProperty = layoutProperty.animatedProperty;

        // Already being animated as part of a different animation?
        // Cancel the animation of this property in that animation, and instead
        // animate as part of a new animation.
        if (animatedProperty != null)
        {
            var existingAnim = animatedProperty.animation;
            if (existingAnim != this)
            {
                existingAnim.RemovePropertyAnim(animatedProperty);
                animatedProperty = null;
            }
        }

        // Create the animated property
        // (But only if necessary: This property may have already been set
        // as part of an animation, but the code may be overriding with a new value)
        if (animatedProperty == null)
        {
            animatedProperty = SAnimatedProperty <T> .Create(_duration, _delay, layoutProperty, this);

            _properties.Add(animatedProperty);
        }

        animatedProperty.start = layoutProperty.getter();
    }
Exemplo n.º 2
0
    void RemovePropertyAnim(SAnimatedProperty animProperty)
    {
        animProperty.Remove();

        // Could potentially make _properties a HashSet rather than List
        // to make this faster, but I think that the Remove is rare enough
        // compared to the Add that it's probably faster to keep it as a list.
        if (_properties != null)
        {
            _properties.Remove(animProperty);
        }
    }