Disable animation after removing the item

4 posts, 0 answers
  1. Vitalii
    Vitalii avatar
    104 posts
    Member since:
    Jul 2013

    Posted 17 May 2014 Link to this post

    I have a SlideView with items that can be removed. After item is removed, SlideView is automatically jumps to the first item, though i'd like it to jump to the next one.

    I tried (i'm using mvvm, so ItemsList is a binded list and ProceedToNextItemEvent is an event my view is subscribed to and calls MySlide.MoveToNextItem())

                ProceedToNextItemEvent(this, null);
                ItemsList.Remove(currentItem);

    But this also triggers jumping to 1 element. Can i disable it?
  2. Vitalii
    Vitalii avatar
    104 posts
    Member since:
    Jul 2013

    Posted 18 May 2014 Link to this post

    Well, i managed to make a workaround, but i dont like it much... In VM, i'm storing current item and firing ProceedToNextItemEvent.

    In the View, i subscribed to OnSlideAnimationCompleted() and calling VM's CommitItemsRemovement. Inside 

    public void CommitItemsRemovement()
            {
                if (itemToRemove != null)
                {
                    if (PreItemRemoveEvent != null) PreItemRemoveEvent(this, null);

                    ItemsList.Remove(itemToRemove);
                    itemToRemove = null;

                    if (PostItemRemoveEvent != null) PostItemRemoveEvent(this, null);
                }
         }

    and in the view again

    private object currentItem;
            private void PreItemRemoveEvent(object _sender, EventArgs _eventArgs)
            {
                currentItem = ProductsSlide.SelectedItem;
            }
            private void PostItemRemoveEvent(object _sender, EventArgs _eventArgs)
            {
                if (currentItem != null)
                    ProductsSlide.SelectedItem = currentItem;
            }

    So, after i pressed "remove" button, i'm saving current item, playing animation, after animation is done i'm checking if saved item is exists, and if yes, i'm saving new current item (where view just navigated to), remove previous item and set current item as SelectedItem. It kinda works, but i'd prefer just to have a property OnItemRemoveJumpToTheFirstItem = false;



















  3. DevCraft banner
  4. Vitalii
    Vitalii avatar
    104 posts
    Member since:
    Jul 2013

    Posted 18 May 2014 Link to this post

    Well, i managed to simplify it by binding SelectedItem to a property, but still it is looking a bit complicated:
    tap (on Remove button) -> animatie to the next item -> animation ends -> save current -> remove previous item (now it should start jumping to 0 item) -> restore current
  5. Todor
    Admin
    Todor avatar
    778 posts

    Posted 21 May 2014 Link to this post

    Hello Vitalii,

    Thank you for writing.

    The complexity of the approach seems to be related to the desired experience. The steps from your last post seem to be the shortest way to achieve the current experience. For example if you don't want to animate to the next item, but instead just "jump to it" when the selected item is removed, you can simply change your selected item property to the next item. Then the steps would be:

    Tap (on Remove button) -> save the currently selected item -> change the selected item property to the next item from your collection -> remove the stored previously selected item.

    If you want the animation to play, there is no other way but the one you are currently using: force animation, wait for its finish and then perform the item removal steps.

    Regards,
    Todor
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top