myDirectives.directive("mouseholdevent", function () { return { restrict: 'A', link: function (scope, element) { var el = element[0]; el.mousehold = true; var setint = ''; var rightClick = false; ele(element).mousedown(function (e) { setint = setInterval(function () { if (rightClick) { clearInterval(setint); } else { if (element.hasClass("zoom_out")) { scope.zoomOutOnCanvasImage(); } else if (element.hasClass("zoom_in")) { scope.zoomInOnCanvasImage(); } } }, 100); }); ele(element).on("mouseleave mouseup contextmenu", function () { rightClick = true; clearInterval(setint); }); } }; });
答案 0 :(得分:0)
myDirectives.directive("mouseholdevent", function () { return { restrict: 'A', link: function (scope, element) { var setint = ''; ele(element).mousedown(function (e) { clearInterval(setint); if (e.button === 2) { return false; } setint = setInterval(function () { if (element.hasClass("zoom_out")) { scope.zoomOutOnCanvasImage(); } else if (element.hasClass("zoom_in")) { scope.zoomInOnCanvasImage(); } }, 100); }); ele(element).on("mouseleave mouseup", function () { clearInterval(setint); }); } }; });