How can i swipe list item using javascript?

I want to trigger swipe event in javascript, how is that possible ?

Are you asking to have an function run on swipe or to simulate the swipe gesture?

i am asking to simulate the swipe gesture.

Hmm good question.

I guess a better question would be to ask what event are you trying to trigger?

I want to close list-item when i click on ion-option-button. It should hide options button and reset the list item state (i.e. Swipe to the right automatically).

Makes sense. Yes this is possible, see my demo.

 $scope.edit = function(item) {
    alert('Edit Item: ' + item.id);
    $ionicListDelegate.closeOptionButtons();
  };

http://ionicframework.com/docs/api/service/$ionicListDelegate/

2 Likes

great @mhartington. Thanks a lot man.

I have an updated codepen with a directive that will close the option button if you attempt to scroll as well.

is there something like $ionicListDelegate.openOptionButtons()?

2 Likes

If it’s not in the docs, then nope :grin:

1 Like

:smiley: how can i implement it ? i damn need it :frowning:. I am not good in angular.

5 Likes

Is there anyway to force an animation of closeOptionButtons()?

Hi men, Did you get it (openOptionButtons)?

Thanks in advance, Nicholls

@jdnichollsc
I managed to simulate the event via javascript when a click event happends on an ion-item

Basically, I managed the click evento so it would add the same translate3d transformation. Once you put the transformation, ionic’s css manages the rest.

Codepen:

2 Likes

Very nicee! Thanks for your response my friend! :smiley:

This is my example with a hold gesture: http://codepen.io/jdnichollsc/pen/YXOqEw

1 Like

Very helpful thread! Thanks guys.