Angular Directive for long press for mobile and desktop
- Works for both mobile (touch) and desktop (mouse) events
- Custom duration can be set
- on-press-end event can be attached
- Include the required source file (this path or similar)
<script src="dist/al-press.js"></script>
- Inject the
al-press
module into your app.
angular.module('app', ['al-press']);
- The basic use is as follows: (event will fire by default after 500ms long press)
<div al-press="onPress()">Click Me</div>
- You can specify a custom duration like below
<div al-press="onPress($event)" duration="1000">Click Me</div>
- You can attach another event that fires on press end
<div al-press on-press-end="onPressEnd()" >Click Me</div>
- In Controller
scope.onPress = function(){
alert('heeey');
};
scope.onPressEnd = function(){
alert('heeey');
};
##Other Directives check out these other useful directives I made:
- alClick: Improved version of ngClick