Permalink
Browse files

Disable preventing of context menu showing for long tap

  • Loading branch information...
DimitryDushkin committed Mar 22, 2015
1 parent 52a090e commit ee7cb0eb782cb66a756874a282456303514fe24d
Showing with 32 additions and 15 deletions.
  1. +21 −11 hammer.js
  2. +3 −3 hammer.min.js
  3. +1 −1 hammer.min.map
  4. +7 −0 src/touchaction.js
View
@@ -1,7 +1,7 @@
/*! Hammer.JS - v2.0.4 - 2014-09-28
/*! Hammer.JS - v2.0.4 - 2015-03-23
* http://hammerjs.github.io/
*
* Copyright (c) 2014 Jorik Tangelder;
* Copyright (c) 2015 Jorik Tangelder;
* Licensed under the MIT license */
(function(window, document, exportName, undefined) {
'use strict';
@@ -320,8 +320,8 @@ function uniqueId() {
* @returns {DocumentView|Window}
*/
function getWindowForElement(element) {
var doc = element.ownerDocument;
return (doc.defaultView || doc.parentWindow);
var doc = element.ownerDocument || element;
return (doc.defaultView || doc.parentWindow || window);
}
var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
@@ -1114,7 +1114,7 @@ TouchAction.prototype = {
value = this.compute();
}
if (NATIVE_TOUCH_ACTION) {
if (NATIVE_TOUCH_ACTION && this.manager.element.style) {
this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
}
this.actions = value.toLowerCase().trim();
@@ -1160,6 +1160,13 @@ TouchAction.prototype = {
return;
}
// disable preventing of context menu to appear for long tap (press)
if (this.manager.options.doNotPreventPress &&
input.distance < 5 &&
input.pointers.length === 1) {
return;
}
var actions = this.actions;
var hasNone = inStr(actions, TOUCH_ACTION_NONE);
var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
@@ -1981,7 +1988,7 @@ inherit(TapRecognizer, Recognizer, {
},
emit: function() {
if (this.state == STATE_RECOGNIZED ) {
if (this.state == STATE_RECOGNIZED) {
this._input.tapCount = this.count;
this.manager.emit(this.options.event, this._input);
}
@@ -2055,12 +2062,12 @@ Hammer.defaults = {
*/
preset: [
// RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
[RotateRecognizer, { enable: false }],
[PinchRecognizer, { enable: false }, ['rotate']],
[SwipeRecognizer,{ direction: DIRECTION_HORIZONTAL }],
[PanRecognizer, { direction: DIRECTION_HORIZONTAL }, ['swipe']],
[RotateRecognizer, {enable: false}],
[PinchRecognizer, {enable: false}, ['rotate']],
[SwipeRecognizer, {direction: DIRECTION_HORIZONTAL}],
[PanRecognizer, {direction: DIRECTION_HORIZONTAL}, ['swipe']],
[TapRecognizer],
[TapRecognizer, { event: 'doubletap', taps: 2 }, ['tap']],
[TapRecognizer, {event: 'doubletap', taps: 2}, ['tap']],
[PressRecognizer]
],
@@ -2381,6 +2388,9 @@ Manager.prototype = {
*/
function toggleCssProps(manager, add) {
var element = manager.element;
if (!element.style) {
return;
}
each(manager.options.cssProps, function(value, name) {
element.style[prefixed(element.style, name)] = add ? value : '';
});
Oops, something went wrong.

0 comments on commit ee7cb0e

Please sign in to comment.