public void CreateAnimatedNode(int tag, JObject config)
        {
            if (_animatedNodes.ContainsKey(tag))
            {
                throw new InvalidOperationException(
                          Invariant($"Animated node with tag '{tag}' already exists."));
            }

            var type = config.Value <string>("type");
            var node = default(AnimatedNode);

            switch (type)
            {
            case "style":
                node = new StyleAnimatedNode(tag, config, this);
                break;

            case "value":
                node = new ValueAnimatedNode(tag, config);
                break;

            case "props":
                node = new PropsAnimatedNode(tag, config, this);
                break;

            case "interpolation":
                node = new InterpolationAnimatedNode(tag, config);
                break;

            case "addition":
                node = new AdditionAnimatedNode(tag, config, this);
                break;

            case "division":
                node = new DivisionAnimatedNode(tag, config, this);
                break;

            case "multiplication":
                node = new MultiplicationAnimatedNode(tag, config, this);
                break;

            case "modulus":
                node = new ModulusAnimatedNode(tag, config, this);
                break;

            case "diffclamp":
                node = new DiffClampAnimatedNode(tag, config, this);
                break;

            case "transform":
                node = new TransformAnimatedNode(tag, config, this);
                break;

            default:
                throw new InvalidOperationException(Invariant($"Unsupported node type: '{type}'"));
            }

            _animatedNodes.Add(tag, node);
            _updatedNodes[tag] = node;
        }
        protected override void OnDetachedFromNode(AnimatedNode parent)
        {
            if (parent != _parent)
            {
                throw new InvalidOperationException("Invalid parent node provided.");
            }

            _parent = null;
        }
Exemple #3
0
 public FrameBasedAnimationDriver(int id, ValueAnimatedNode animatedValue, ICallback endCallback, JObject config)
     : base(id, animatedValue, endCallback)
 {
     _frames      = config.GetValue("frames", StringComparison.Ordinal).ToObject <double[]>();
     _toValue     = config.Value <double>("toValue");
     _iterations  = config.ContainsKey("iterations") ? config.Value <int>("iterations") : 1;
     _currentLoop = 1;
     HasFinished  = _iterations == 0;
 }
        protected override void OnDetachedFromNode(AnimatedNode parent)
        {
            if (parent != _parent)
            {
                throw new InvalidOperationException("Invalid parent node provided.");
            }

            _parent = null;
        }
 public DecayAnimationDriver(int id, ValueAnimatedNode animatedValue, ICallback endCallback, JObject config)
     : base(id, animatedValue, endCallback)
 {
     _velocity     = config.Value <double>("velocity");
     _deceleration = config.Value <double>("deceleration");
     _iterations   = config.ContainsKey("iterations") ? config.Value <int>("iterations") : 1;
     _currentLoop  = 1;
     HasFinished   = _iterations == 0;
 }
 public SpringAnimationDriver(int id, ValueAnimatedNode animatedValue, ICallback endCallback, JObject config)
     : base(id, animatedValue, endCallback)
 {
     _springFriction        = config.Value <double>("friction");
     _springTension         = config.Value <double>("tension");
     _currentState.Velocity = config.Value <double>("initialVelocity");
     _endValue                      = config.Value <double>("toValue");
     _restSpeedThreshold            = config.Value <double>("restSpeedThreshold");
     _displacementFromRestThreshold = config.Value <double>("restDisplacementThreshold");
     _overshootClampingEnabled      = config.Value <bool>("overshootClamping");
 }
        protected override void OnAttachedToNode(AnimatedNode parent)
        {
            if (_parent != null)
            {
                throw new InvalidOperationException("Parent already attached.");
            }

            var valueNode = parent as ValueAnimatedNode;
            if (valueNode == null)
            {
                throw new InvalidOperationException("Parent is not a value node.");
            }

            _parent = valueNode;
        }
 public SpringAnimationDriver(int id, ValueAnimatedNode animatedValue, ICallback endCallback, JObject config)
     : base(id, animatedValue, endCallback)
 {
     _springStiffness       = config.Value <double>("stiffness");
     _springDamping         = config.Value <double>("damping");
     _springMass            = config.Value <double>("mass");
     _initialVelocity       = config.Value <double>("initialVelocity");
     _currentState.Velocity = _initialVelocity;
     _endValue                      = config.Value <double>("toValue");
     _restSpeedThreshold            = config.Value <double>("restSpeedThreshold");
     _displacementFromRestThreshold = config.Value <double>("restDisplacementThreshold");
     _overshootClampingEnabled      = config.Value <bool>("overshootClamping");
     _iterations                    = config.ContainsKey("iterations") ? config.Value <int>("iterations") : 1;
     HasFinished                    = _iterations == 0;
 }
        protected override void OnAttachedToNode(AnimatedNode parent)
        {
            if (_parent != null)
            {
                throw new InvalidOperationException("Parent already attached.");
            }

            var valueNode = parent as ValueAnimatedNode;

            if (valueNode == null)
            {
                throw new InvalidOperationException("Parent is not a value node.");
            }

            _parent = valueNode;
        }
        public SpringAnimationDriver(int id, ValueAnimatedNode animatedValue, ICallback endCallback, JObject config)
            : base(id, animatedValue, endCallback)
        {
            _springFriction        = config.Value <double>("friction");
            _springTension         = config.Value <double>("tension");
            _currentState.Velocity = config.Value <double>("initialVelocity");
            _endValue                      = config.Value <double>("toValue");
            _restSpeedThreshold            = config.Value <double>("restSpeedThreshold");
            _displacementFromRestThreshold = config.Value <double>("restDisplacementThreshold");
            _overshootClampingEnabled      = config.Value <bool>("overshootClamping");


            Log.Info(ReactConstants.Tag, "## _springFriction = " + _springFriction + ", _springTension=" + _springTension
                     + ", Velocity=" + _currentState.Velocity + "_endValue=" + _endValue + ", _restSpeedThreshold=" + _restSpeedThreshold
                     + ", _displacementFromRestThreshold=" + _displacementFromRestThreshold + ", _overshootClampingEnabled=" + _overshootClampingEnabled);
        }
 public EventAnimationDriver(IList <string> eventPath, ValueAnimatedNode valueNode)
 {
     _eventPath = eventPath;
     ValueNode  = valueNode;
 }
 public FrameBasedAnimationDriver(int id, ValueAnimatedNode animatedValue, ICallback endCallback, JObject config)
     : base(id, animatedValue, endCallback)
 {
     _frames = config.GetValue("frames", StringComparison.Ordinal).ToObject<double[]>();
     _toValue = config.Value<double>("toValue");
 }
 public DecayAnimationDriver(int id, ValueAnimatedNode animatedValue, ICallback endCallback, JObject config)
     : base(id, animatedValue, endCallback)
 {
     _velocity = config.Value<double>("velocity");
     _deceleration = config.Value<double>("deceleration");
 }
Exemple #14
0
 public AnimationDriver(int id, ValueAnimatedNode animatedValue, ICallback endCallback)
 {
     Id            = id;
     AnimatedValue = animatedValue;
     EndCallback   = endCallback;
 }
 public DecayAnimationDriver(int id, ValueAnimatedNode animatedValue, ICallback endCallback, JObject config)
     : base(id, animatedValue, endCallback)
 {
     _velocity     = config.Value <double>("velocity");
     _deceleration = config.Value <double>("deceleration");
 }
Exemple #16
0
 public FrameBasedAnimationDriver(int id, ValueAnimatedNode animatedValue, ICallback endCallback, JObject config)
     : base(id, animatedValue, endCallback)
 {
     _frames  = config.GetValue("frames").ToObject <double[]>();
     _toValue = config.Value <double>("toValue");
 }