* set the touchAction value on the element or enable the polyfill
1214 * @param {String} value 1216 set: function(value) { 1217 // find out the touch-action by the event handlers 1218 if (value == TOUCH_ACTION_COMPUTE) { 1219 value = this.compute(); 1222 if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) { 1223 this.manager.element.style[PREFIXED_TOUCH_ACTION] = value; 1225 this.actions = value.toLowerCase().trim(); 1229 * just re-set the touchAction value 1231 update: function() { 1232 this.set(this.manager.options.touchAction); 1236 * compute the value for the touchAction property based on the recognizer's settings 1237 * @returns {String} value 1239 compute: function() { 1241 each(this.manager.recognizers, function(recognizer) { 1242 if (boolOrFn(recognizer.options.enable, [recognizer])) { 1243 actions = actions.concat(recognizer.getTouchAction()); 1246 return cleanTouchActions(actions.join(' ')); 1250 * this method is called on each input cycle and provides the preventing of the browser behavior 1251 * @param {Object} input 1253 preventDefaults: function(input) { 1254 var srcEvent = input.srcEvent; 1255 var direction = input.offsetDirection; 1257 // if the touch action did prevented once this session 1258 if (this.manager.session.prevented) { 1259 srcEvent.preventDefault(); 1263 var actions = this.actions; 1264 var hasNone = inStr(actions, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE]; 1265 var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y]; 1266 var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X]; 1269 //do not prevent defaults if this is a tap gesture 1271 var isTapPointer = input.pointers.length === 1; 1272 var isTapMovement = input.distance < 2; 1273 var isTapTouchTime = input.deltaTime < 250; 1275 if (isTapPointer && isTapMovement && isTapTouchTime) { 1280 if (hasPanX && hasPanY) { 1281 // `pan-x pan-y` means browser handles all scrolling/panning, do not prevent 1286 (hasPanY && direction & DIRECTION_HORIZONTAL) || 1287 (hasPanX && direction & DIRECTION_VERTICAL)) { 1288 return this.preventSrc(srcEvent); 1293 * call preventDefault to prevent the browser's default behavior (scrolling in most cases) 1294 * @param {Object} srcEvent 1296 preventSrc: function(srcEvent) { 1297 this.manager.session.prevented = true; 1298 srcEvent.preventDefault();