protected override void OnDisable()
        {
            // Make sure no animation will continue next time the object is enabled, in case the disabling is just temporary
            _ExpandCollapseAnimation = null;

            base.OnDisable();
        }
        void OnExpandCollapseButtonClicked(MyVH vh)
        {
            // Force finish previous animation
            if (_ExpandCollapseAnimation != null)
            {
                int oldItemIndex = _ExpandCollapseAnimation.itemIndex;
                var oldModel     = LazyData.GetOrCreate(oldItemIndex);
                _ExpandCollapseAnimation.ForceFinish();
                oldModel.ExpandedAmount = _ExpandCollapseAnimation.CurrentExpandedAmount;
                UpdateModelAndResizeViewsHolderIfVisible(oldItemIndex, oldModel);
                _ExpandCollapseAnimation = null;
            }

            var model = LazyData.GetOrCreate(vh.ItemIndex);

            var anim = new ExpandCollapseAnimationState(_Params.UseUnscaledTime);

            anim.initialExpandedAmount = model.ExpandedAmount;
            anim.duration = .2f;
            if (model.ExpandedAmount == 1f)             // fully expanded
            {
                anim.targetExpandedAmount = 0f;
            }
            else
            {
                anim.targetExpandedAmount = 1f;
            }

            anim.itemIndex = vh.ItemIndex;

            _ExpandCollapseAnimation = anim;
        }
        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
            _ExpandCollapseAnimation = null;

            base.ChangeItemsCount(changeMode, itemsCount, indexIfInsertingOrRemoving, contentPanelEndEdgeStationary, keepVelocity);
        }
        void AdvanceExpandCollapseAnimation()
        {
            int itemIndex = _ExpandCollapseAnimation.itemIndex;
            var model     = LazyData.GetOrCreate(itemIndex);

            model.ExpandedAmount = _ExpandCollapseAnimation.CurrentExpandedAmount;
            UpdateModelAndResizeViewsHolderIfVisible(itemIndex, model);

            if (_ExpandCollapseAnimation.IsDone)
            {
                _ExpandCollapseAnimation = null;
            }
        }