Angular Mouseup似乎不会发射

时间:2016-08-14 00:47:21

标签: javascript angularjs mobile

我相信我有一个与此有关的问题:Deferred long-running timer task(s) to improve scrolling smoothness

我在移动版中遇到过只有鼠标事件无法触发的问题。我认为我使用$interval()是一个问题?我经常解雇它会以某种方式使移动浏览器无法捕获其他事件吗?

我的代码:

$scope.problem = {onHammer : function(event) {
        var count = 0;
        $scope.promisey.promise = $interval(function () { 
           count++;
         if (count > 3)
         {
        //alert("Trigged Press Down Clear");
        console.log(event);
        var itemValue = event.target.attributes.data.value;
        for (var r = 0; r < $scope.itemsSelected.length; r++) {
            if ($scope.itemsSelected[r].bread == itemValue) {
                for (var x = 0; x < $scope.breads.length; x++) {
                    if ($scope.breads[x].Name == itemValue) {
                        $scope.breads[x].selected = [""];
                        console.log($scope.breads);
                        break;
                    }
                }
                $scope.itemsSelected.splice(r, 1);
                $scope.calculate();
                event.target.attributes.datalastManipulation.value = new Date();
                break;
            }
        }
        }
        }, 40);
    },
    onHammerUp: function(event){
        //alert("Up");
        console.log(event);
        $interval.cancel($scope.promisey.promise);
    },
onHammer()ng-mousedown onHammerUp()上调用{p> ng-mouseup。最终发生的事情是mouseup()永远不会取消$interval()所以我得到了无数个console.log()提到mousedown事件但从来没有取鼠标。我在移动设备上做错了什么?

修改:HTML

<div ng-repeat="bread in breads | filter:{ Name: textInputSearch } | filter:{ Type: toggleV }">
<div class="clearfix" ng-if="$index % 4 == 0"></div>
<div class="col-xs-3">
<img id="@{{bread.Name}}" ng-mousedown="$parent.problem.onHammer($event)" ng-mouseup="$parent.problem.onHammerUp($event)" ng-click="$parent.problem.select($event)" ng-class="bread.selected" ng-src="images/items/@{{bread.Picture}}" data="@{{bread.Name}}" datalastManipulation="" dataprice="@{{bread.Price}}" style="cursor:pointer;width: 90%;" class="disableSave" oncontextmenu="return false;"></img><i ng-if="bread.NotAvailable" class="cali fa fa-calendar"></i><p>@{{bread.Name}} <i style="cursor:pointer;" ng-click="info(bread.Name)" class="fa fa-info-circle" aria-hidden="true"></i></p>
</div>
</div>

我在开发工具中检查了我的chrome时间轴,但我确实有长帧导致问题,但我不知道如何解决它。我不明白为什么Timer Fired会继续进行桌面记录,其中mouseup应取消正在触发的计时器。任何有关这方面的帮助将不胜感激。

0 个答案:

没有答案
相关问题