Пример #1
0
        protected override void OnDisable()
        {
            // Make sure no animation will continue next time the object is enabled, in case the disabling is just temporary
            _InsertDeleteAnimation = null;

            base.OnDisable();
        }
Пример #2
0
        /// <inheritdoc/>
        public override void ChangeItemsCount(ItemCountChangeMode changeMode, int itemsCount, int indexIfInsertingOrRemoving = -1, bool contentPanelEndEdgeStationary = false, bool keepVelocity = false)
        {
            // No animation should be preserved between count changes.
            // In case of insertion and removals, we don't touch it, since we expect those to be handled by the AnimatedInsert and AnimatedRemove, respectively
            if (changeMode == ItemCountChangeMode.RESET)
            {
                _InsertDeleteAnimation = null;
            }

            base.ChangeItemsCount(changeMode, itemsCount, indexIfInsertingOrRemoving, contentPanelEndEdgeStationary, keepVelocity);
        }
Пример #3
0
        void OnCurrentInsertDeleteAnimationFinished()
        {
            int itemIndex = _InsertDeleteAnimation.itemIndex;

            if (!_InsertDeleteAnimation.IsInsert)
            {
                // The animation was a remove animation => The item needs to be removed at the end of it
                LazyData.RemoveItems(itemIndex, 1, false);
            }

            _InsertDeleteAnimation = null;
        }
Пример #4
0
        /// <summary>Inserting now, then animating</summary>
        public void AnimatedInsert(int index, MyModel model)
        {
            // Force finish previous animation
            if (_InsertDeleteAnimation != null)
            {
                ForceFinishCurrentAnimation();

                if (index > LazyData.Count)
                {
                    // The previous animation was a removal and this index is not valid anymore
                    return;
                }
            }

            _InsertDeleteAnimation = new InsertDeleteAnimationState(_Params.UseUnscaledTime, index, 0f, 1f);
            LazyData.InsertOneManuallyCreated(index, model, false);
        }
Пример #5
0
        /// <summary>Animating removal, then remove</summary>
        public void AnimatedRemove(int index)
        {
            // Force finish previous animation
            if (_InsertDeleteAnimation != null)
            {
                ForceFinishCurrentAnimation();

                if (index >= LazyData.Count)
                {
                    // The previous animation was a removal and this index is not valid anymore
                    return;
                }
            }

            var model = LazyData.GetOrCreate(index);

            _InsertDeleteAnimation = new InsertDeleteAnimationState(_Params.UseUnscaledTime, index, model.expandedAmount, 0f);
        }