目录

Tap Hold Event (Long Tap)

优质
小牛编辑
136浏览
2023-12-01

Framework7 has so called "tap hold" event. It triggers (if enabled) after a sustained, complete touch event. By default it is disabled and could be enabled and configured using the following App paremeters on app initialization:

Parameter Type Default Description
tapHold boolean false Set to true to enable tap hold events
tapHoldDelay number 750 Determines how long (in ms) the user must hold their tap before the taphold event is fired on the target element
tapHoldPreventClicks boolean true When enabled (by default), then click event will not be fired after tap hold event

Note, that Tap Hold is a part of built-in Fast Clicks library, so Fast Clicks should be also enabled.

Also note, that you probably will need to disable mobile browser default "long-tap" actions by adding these CSS rules to elements:

-moz-user-select: none;        
-webkit-user-select: none;        
user-select: none;

Example

var myApp = new Framework7({
  tapHold: true //enable tap hold events
});
 
var $$ = Dom7;
 
$$('.some-link').on('taphold', function () {
  myApp.alert('Tap hold fired!');
});