Thursday, January 17, 2019

Ionic - Javascript Events



Various Ionic events can be used to add interactivity with users. The following table explains all the Ionic events.
Event NameEvent Detail
on-holdCalled when duration of the touch is more than 500ms.
on-tapCalled when duration of the touch is less than 250ms.
on-double-tapCalled when there is double tap touch.
on-touchCalled immediately when touch begins.
on-releaseCalled when touch ends.
on-dragCalled when touch is moved without releasing around the page in any direction.
on-drag-upCalled when element is dragged up.
on-drag-rightCalled when the element is dragged to the right.
on-drag-leftCalled when the element is dragged to the left.
on-drag-downCalled when the element is dragged down.
on-swipeCalled when any dragging has high velocity moving in any direction.
on-swipe-upCalled when any dragging has high velocity moving up.
on-swipe-rightCalled when any dragging has high velocity moving to the right.
on-swipe-leftCalled when any dragging has high velocity moving to the left.
on-swipe-downCalled when any dragging has high velocity moving down.

Using Events

Since all the Ionic events can be used the same way, we will show you how to use the on-touch event and you can just apply the same principles to the other events. To start with, we will create a button and assign an on-touchevent, which will call the onTouchFunction().
<button on-touch = "onTouchFunction()" class="button">Test</button>
Then we will create that function in our controller scope.
$scope.onTouchFunction = function() {
   // Do something...
}
Now, when touch event occurs the onTouchFunction() will be called.

No comments:

Post a Comment