public TransformAnimatedNode(int tag, JObject config, NativeAnimatedNodesManager manager)
            : base(tag)
        {
            _manager = manager;

            var transforms = (JArray)config.GetValue("transforms", StringComparison.Ordinal);

            _transformConfigs = new List <TransformConfig>(transforms.Count);
            for (var i = 0; i < transforms.Count; ++i)
            {
                var transformConfigMap = transforms[i];
                var property           = transformConfigMap.Value <string>("property");
                var type = transformConfigMap.Value <string>("type");
                if (type == "animated")
                {
                    _transformConfigs.Add(new AnimatedTransformConfig
                    {
                        Property = property,
                        NodeTag  = transformConfigMap.Value <int>("nodeTag"),
                    });
                }
                else
                {
                    _transformConfigs.Add(new StaticTransformConfig
                    {
                        Property = property,
                        Value    = transformConfigMap.Value <double>("value"),
                    });
                }
            }
        }
Esempio n. 2
0
 public ModulusAnimatedNode(int tag, JObject config, NativeAnimatedNodesManager manager)
     : base(tag)
 {
     _manager   = manager;
     _inputNode = config.Value <int>("input");
     _modulus   = config.Value <int>("modulus");
 }
Esempio n. 3
0
        public DiffClampAnimatedNode(int tag, JObject config, NativeAnimatedNodesManager manager)
            : base(tag, config)
        {
            _manager      = manager;
            _inputNodeTag = config.Value <int>("input");
            _min          = config.Value <double>("min");
            _max          = config.Value <double>("max");

            Value = _lastValue = GetInputNodeValue();
        }
Esempio n. 4
0
        /// <summary>
        /// Called after the creation of a <see cref="IReactInstance"/>, in
        /// order to initialize native modules that require the React or
        /// JavaScript modules.
        /// </summary>
        public override void Initialize()
        {
            Log.Info(ReactConstants.Tag, "## NativeAnimatedModule Initialize ##");
            //var ctx = Context;
            //var uiManager = ctx.GetNativeModule<UIManagerModule>();
            //var nodesManager = new NativeAnimatedNodesManager(uiManager);

            var ctx = Context;

            _uiMgrModule       = ctx.GetNativeModule <UIManagerModule>();
            _nativeAnimnodeMgr = new NativeAnimatedNodesManager(_uiMgrModule);

            /*
             * // Register the frame callback, instead of relevant cb of EFL
             * _animatedFrameCallback = (sender, args) =>
             * {
             *  try
             *  {
             *      var renderingArgs = args as RenderingEventArgs;
             *      if (renderingArgs == null)
             *      {
             *          return;
             *      }
             *
             *      var operations = default(List<Action<NativeAnimatedNodesManager>>);
             *      lock (_operationsGate)
             *      {
             *          operations = _readyOperations;
             *          _readyOperations = null;
             *      }
             *
             *      if (operations != null)
             *      {
             *          foreach (var operation in operations)
             *          {
             *              operation(nodesManager);
             *          }
             *      }
             *
             *      if (nodesManager.HasActiveAnimations)
             *      {
             *          nodesManager.RunUpdates(renderingArgs.RenderingTime);
             *      }
             *  }
             *  catch (Exception ex)
             *  {
             *      Context.HandleException(ex);
             *  }
             * };
             */

            ctx.AddLifecycleEventListener(this);
        }
        public TrackingAnimatedNode(int tag, JObject config, NativeAnimatedNodesManager manager)
            : base(tag)
        {
            _manager     = manager;
            _animationId = config.Value <int>("animationId");
            _toValueNode = config.Value <int>("toValue");
            _valueNode   = config.Value <int>("value");

            var animationConfig = config.Value <JObject>("animationConfig");

            _animationConfig = (JObject)animationConfig.DeepClone();
        }
Esempio n. 6
0
        public PropsAnimatedNode(int tag, JObject config, NativeAnimatedNodesManager manager)
            : base(tag)
        {
            _manager = manager;

            var props = (JObject)config.GetValue("props");

            _propMapping = new Dictionary <string, int>(props.Count);
            foreach (var entry in props)
            {
                _propMapping.Add(entry.Key, entry.Value.Value <int>());
            }
        }
        public StyleAnimatedNode(int tag, JObject config, NativeAnimatedNodesManager manager)
            : base(tag)
        {
            _manager = manager;

            var style = (JObject)config.GetValue("style", StringComparison.Ordinal);

            _propMapping = new Dictionary <string, int>(style.Count);
            foreach (var entry in style)
            {
                _propMapping.Add(entry.Key, entry.Value.Value <int>());
            }
        }
Esempio n. 8
0
        public PropsAnimatedNode(int tag, JObject config, NativeAnimatedNodesManager manager, UIImplementation uiImplementation)
            : base(tag)
        {
            var props = (JObject)config.GetValue("props", StringComparison.Ordinal);

            _propNodeMapping = new Dictionary <string, int>(props.Count);
            foreach (var entry in props)
            {
                _propNodeMapping.Add(entry.Key, entry.Value.Value <int>());
            }

            _propMap          = new JObject();
            _manager          = manager;
            _uiImplementation = uiImplementation;
        }
Esempio n. 9
0
        /// <summary>
        /// Called after the creation of a <see cref="IReactInstance"/>, in
        /// order to initialize native modules that require the React or
        /// JavaScript modules.
        /// </summary>
        public override void Initialize()
        {
            var ctx          = Context;
            var uiImpl       = ctx.GetNativeModule <UIManagerModule>().UIImplementation;
            var nodesManager = new NativeAnimatedNodesManager(uiImpl);

            _animatedFrameCallback = (sender, args) =>
            {
                try
                {
                    var renderingArgs = args as RenderingEventArgs;
                    if (renderingArgs == null)
                    {
                        return;
                    }

                    var operations = default(List <Action <NativeAnimatedNodesManager> >);
                    lock (_operationsGate)
                    {
                        operations       = _readyOperations;
                        _readyOperations = null;
                    }

                    if (operations != null)
                    {
                        foreach (var operation in operations)
                        {
                            operation(nodesManager);
                        }
                    }

                    if (nodesManager.HasActiveAnimations)
                    {
                        nodesManager.RunUpdates(renderingArgs.RenderingTime);
                    }
                }
                catch (Exception ex)
                {
                    Context.HandleException(ex);
                }
            };

            ctx.AddLifecycleEventListener(this);
        }
Esempio n. 10
0
        /// <summary>
        /// Called after the creation of a <see cref="IReactInstance"/>, in
        /// order to initialize native modules that require the React or
        /// JavaScript modules.
        /// </summary>
        public override void Initialize()
        {
            var ctx          = Context;
            var uiManager    = ctx.GetNativeModule <UIManagerModule>();
            var nodesManager = new NativeAnimatedNodesManager(uiManager);

            _animatedFrameCallback = (sender, args) =>
            {
                try
                {
                    var operations = default(List <Action <NativeAnimatedNodesManager> >);
                    lock (_operationsGate)
                    {
                        operations       = _readyOperations;
                        _readyOperations = null;
                    }

                    if (operations != null)
                    {
                        foreach (var operation in operations)
                        {
                            operation(nodesManager);
                        }
                    }

                    if (nodesManager.HasActiveAnimations)
                    {
                        nodesManager.RunUpdates(args.RenderingTime);
                    }
                    else
                    {
                        ReactChoreographer.Instance.DeactivateCallback(nameof(NativeAnimatedModule));
                    }
                }
                catch (Exception ex)
                {
                    Context.HandleException(ex);
                }
            };

            ctx.AddLifecycleEventListener(this);
        }
 public MultiplicationAnimatedNode(int tag, JObject config, NativeAnimatedNodesManager manager)
     : base(tag)
 {
     _manager    = manager;
     _inputNodes = config.GetValue("input", StringComparison.Ordinal).ToObject <int[]>();
 }
Esempio n. 12
0
 public AdditionAnimatedNode(int tag, JObject config, NativeAnimatedNodesManager manager)
     : base(tag)
 {
     _manager    = manager;
     _inputNodes = config.GetValue("input").ToObject <int[]>();
 }