没有jquery的移动鼠标悬停事件

Mousedown event for mobile without jquery?

本文关键字:悬停 事件 鼠标 移动 jquery 没有      更新时间:2023-09-26

是否有一个简单的mousedown/mouseup事件可以用于基于Angular的移动应用程序

我已经在使用ngTouch进行一些滑动,但它似乎不支持"按下时"类型的事件。

ngMousedown在触摸屏上不起作用,如果可能的话,我想避免使用jquery。我想要一些我可以坚持到指令中并应用于一堆不同元素的东西。

我刚刚使用了jquery。这是一个指令,在触摸屏设备上按下项目时应用类。本质上是一个在触摸屏上工作的ngmousedown

angular.module('app.directives').directive('touchable', function() {
    return {
    restrict: 'A',
    transclude: false,
    scope: false,
    link: function(scope, element, attrs){
        element.on('touchstart', function(){
            $(this).addClass('pressed');
        }).on('touchend', function(){
            $(this).removeClass('pressed');
        });
    }}
});