Skip to content

Commit

Permalink
Merge pull request #2511 in SW/shopware from bugfix/next/sw-11181-adv…
Browse files Browse the repository at this point in the history
…anced-menu-fix to next

* commit '19cf7e161f704ef810a41ccfd91496de0f88344b':
  SW-11181 - fixed advanced menu on desktop, tablets and surface
  • Loading branch information
Marcel Schmäing committed Apr 27, 2015
2 parents d4f6c23 + 19cf7e1 commit bb35011
Showing 1 changed file with 22 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,7 @@
*
* @type {String}
*/
'itemHoverClass': 'is--hovered',

/**
* Tolerance the touch should be counted as a tap.
*
* @type {Number}
*/
'touchTimeTolerance': 100
'itemHoverClass': 'is--hovered'
},

/**
Expand Down Expand Up @@ -113,14 +106,6 @@
*/
me._$closeButton = me.$el.find(me.opts.closeButtonSelector);

/**
* Timestamp of the last touch start on a list item.
*
* @private
* @property _touchStartTimestamp
* @type {Number}
*/
me._touchStartTimestamp = 0;

/**
* PreviousTarget will be used for pointer events to prevent
Expand Down Expand Up @@ -151,13 +136,12 @@
$.each(me._$listItems, function (i, el) {
$el = $(el);

me._on($el, 'touchstart', $.proxy(me.onTouchStart, me));

me._on($el, 'mouseenter', $.proxy(me.onListItemEnter, me, i, $el));

if (window.navigator.pointerEnabled || window.navigator.msPointerEnabled) {

me._on($el, 'click', $.proxy(me.onClickNavigationLink, me, i, $el))
} else {
me._on($el, 'click', $.proxy(me.onClick, me, i, $el));
}
});

Expand All @@ -167,14 +151,26 @@
},

/**
* Called when a touch started on a list item.
* Updates the timestamp property to determine a tap on touch end.
* Called when a click event is triggered.
* If touch is available preventing default behaviour.
*
* @public
* @method onTouchStart
* @param event
*/
onClick: function () {
var me = this;

if(me.isTouchDevice()) {
event.preventDefault();
}
},

/**
* Detecting touch device.
*
* @returns {boolean}
*/
onTouchStart: function () {
this._touchStartTimestamp = Date.now();
isTouchDevice: function() {
return true == ("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch);
},

/**
Expand All @@ -191,7 +187,7 @@

event.stopPropagation();

if (!(event.originalEvent instanceof MouseEvent) && (Date.now() - me._touchStartTimestamp > opts.touchTimeTolerance)) {
if (!(event.originalEvent instanceof MouseEvent)) {
event.preventDefault();
return;
}
Expand Down

0 comments on commit bb35011

Please sign in to comment.