如何阻止$ionicGesture
事件'拖动'在' pinchin'之后或者' pinchout'?
我已尝试e.preventDefault()
,e.gesture.preventDefault()
,但仍会触发拖动事件。
$ionicGesture.on("drag", function (e) {
cursor_gesture = e.gesture;
cursor_center = cursor_gesture.center;
_drag_to_edit();
}, photo);
$ionicGesture.on("pinchin", function (e) {
console.log(e);
e.preventDefault();
}, photo);
$ionicGesture.on("pinchout", function (e) {
console.log(e);
.preventDefault();
}, photo);
答案 0 :(得分:0)
你也可以试试这些:
event.preventDefault();
event.stopPropagation();
event.gesture.stopPropagation();
event.gesture.preventDefault();
event.gesture.stopDetect();
答案 1 :(得分:0)
在给定的时间内手动阻止其他事件处理程序:
var lastPinchTime = undefined;
var dragBlockTimeAmmount = 1000; //1 second
$ionicGesture.on("drag", function (e) {
if( (new Date() - lastPinchTime) < dragBlockTimeAmmount){
e.preventDefault();
}
else {
// ...
// your code here
// ...
}
}, photo);
$ionicGesture.on("pinchin", function (e) {
lastPinchTime = new Date();
}, photo);
$ionicGesture.on("pinchout", function (e) {
lastPinchTime = new Date();
}, photo);