How can i swipe list item using javascript?


#1

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


#2

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


#3

i am asking to simulate the swipe gesture.


Swipeable item list how to swipeback the row after event trigged
#4

Hmm good question.

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


#5

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).


#6

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/


Swipe-back to option buttons
#7

great @mhartington. Thanks a lot man.


#8

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


#9

is there something like $ionicListDelegate.openOptionButtons()?


#10

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


#11

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


#12

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


#13

Hi men, Did you get it (openOptionButtons)?

Thanks in advance, Nicholls


#14

@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:


How do open ion-option-button?
#15

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

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


#16

Very helpful thread! Thanks guys.