Skip to content

Commit bb35011

Browse files
author
Marcel Schmäing
committed
Merge pull request #2511 in SW/shopware from bugfix/next/sw-11181-advanced-menu-fix to next
* commit '19cf7e161f704ef810a41ccfd91496de0f88344b': SW-11181 - fixed advanced menu on desktop, tablets and surface
2 parents d4f6c23 + 19cf7e1 commit bb35011

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

engine/Shopware/Plugins/Default/Frontend/AdvancedMenu/Views/frontend/_public/src/js/jquery.advanced-menu.js

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,7 @@
6060
*
6161
* @type {String}
6262
*/
63-
'itemHoverClass': 'is--hovered',
64-
65-
/**
66-
* Tolerance the touch should be counted as a tap.
67-
*
68-
* @type {Number}
69-
*/
70-
'touchTimeTolerance': 100
63+
'itemHoverClass': 'is--hovered'
7164
},
7265

7366
/**
@@ -113,14 +106,6 @@
113106
*/
114107
me._$closeButton = me.$el.find(me.opts.closeButtonSelector);
115108

116-
/**
117-
* Timestamp of the last touch start on a list item.
118-
*
119-
* @private
120-
* @property _touchStartTimestamp
121-
* @type {Number}
122-
*/
123-
me._touchStartTimestamp = 0;
124109

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

154-
me._on($el, 'touchstart', $.proxy(me.onTouchStart, me));
155-
156139
me._on($el, 'mouseenter', $.proxy(me.onListItemEnter, me, i, $el));
157140

158141
if (window.navigator.pointerEnabled || window.navigator.msPointerEnabled) {
159-
160142
me._on($el, 'click', $.proxy(me.onClickNavigationLink, me, i, $el))
143+
} else {
144+
me._on($el, 'click', $.proxy(me.onClick, me, i, $el));
161145
}
162146
});
163147

@@ -167,14 +151,26 @@
167151
},
168152

169153
/**
170-
* Called when a touch started on a list item.
171-
* Updates the timestamp property to determine a tap on touch end.
154+
* Called when a click event is triggered.
155+
* If touch is available preventing default behaviour.
172156
*
173-
* @public
174-
* @method onTouchStart
157+
* @param event
158+
*/
159+
onClick: function () {
160+
var me = this;
161+
162+
if(me.isTouchDevice()) {
163+
event.preventDefault();
164+
}
165+
},
166+
167+
/**
168+
* Detecting touch device.
169+
*
170+
* @returns {boolean}
175171
*/
176-
onTouchStart: function () {
177-
this._touchStartTimestamp = Date.now();
172+
isTouchDevice: function() {
173+
return true == ("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch);
178174
},
179175

180176
/**
@@ -191,7 +187,7 @@
191187

192188
event.stopPropagation();
193189

194-
if (!(event.originalEvent instanceof MouseEvent) && (Date.now() - me._touchStartTimestamp > opts.touchTimeTolerance)) {
190+
if (!(event.originalEvent instanceof MouseEvent)) {
195191
event.preventDefault();
196192
return;
197193
}

0 commit comments

Comments
 (0)