📜  Ionic-Javascript事件

📅  最后修改于: 2020-12-08 05:04:30             🧑  作者: Mango


各种离子事件可以用来增加与用户的交互性。下表说明了所有离子事件。

Event Name Event Detail
on-hold Called when duration of the touch is more than 500ms.
on-tap Called when duration of the touch is less than 250ms.
on-double-tap Called when there is double tap touch.
on-touch Called immediately when touch begins.
on-release Called when touch ends.
on-drag Called when touch is moved without releasing around the page in any direction.
on-drag-up Called when element is dragged up.
on-drag-right Called when the element is dragged to the right.
on-drag-left Called when the element is dragged to the left.
on-drag-down Called when the element is dragged down.
on-swipe Called when any dragging has high velocity moving in any direction.
on-swipe-up Called when any dragging has high velocity moving up.
on-swipe-right Called when any dragging has high velocity moving to the right.
on-swipe-left Called when any dragging has high velocity moving to the left.
on-swipe-down Called when any dragging has high velocity moving down.

使用事件

由于可以以相同方式使用所有离子事件,因此我们将向您展示如何使用触摸事件,并且可以将相同的原理应用于其他事件。首先,我们将创建一个按钮并分配一个on-touch事件,该事件将调用onTouchFunction()


然后,我们将在控制器范围内创建该函数。

$scope.onTouchFunction = function() {
   // Do something...
}

现在,当触摸事件发生时,将调用onTouchFunction()