|
60 | 60 | * |
61 | 61 | * @type {String} |
62 | 62 | */ |
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' |
71 | 64 | }, |
72 | 65 |
|
73 | 66 | /** |
|
113 | 106 | */ |
114 | 107 | me._$closeButton = me.$el.find(me.opts.closeButtonSelector); |
115 | 108 |
|
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; |
124 | 109 |
|
125 | 110 | /** |
126 | 111 | * PreviousTarget will be used for pointer events to prevent |
|
151 | 136 | $.each(me._$listItems, function (i, el) { |
152 | 137 | $el = $(el); |
153 | 138 |
|
154 | | - me._on($el, 'touchstart', $.proxy(me.onTouchStart, me)); |
155 | | - |
156 | 139 | me._on($el, 'mouseenter', $.proxy(me.onListItemEnter, me, i, $el)); |
157 | 140 |
|
158 | 141 | if (window.navigator.pointerEnabled || window.navigator.msPointerEnabled) { |
159 | | - |
160 | 142 | me._on($el, 'click', $.proxy(me.onClickNavigationLink, me, i, $el)) |
| 143 | + } else { |
| 144 | + me._on($el, 'click', $.proxy(me.onClick, me, i, $el)); |
161 | 145 | } |
162 | 146 | }); |
163 | 147 |
|
|
167 | 151 | }, |
168 | 152 |
|
169 | 153 | /** |
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. |
172 | 156 | * |
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} |
175 | 171 | */ |
176 | | - onTouchStart: function () { |
177 | | - this._touchStartTimestamp = Date.now(); |
| 172 | + isTouchDevice: function() { |
| 173 | + return true == ("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch); |
178 | 174 | }, |
179 | 175 |
|
180 | 176 | /** |
|
191 | 187 |
|
192 | 188 | event.stopPropagation(); |
193 | 189 |
|
194 | | - if (!(event.originalEvent instanceof MouseEvent) && (Date.now() - me._touchStartTimestamp > opts.touchTimeTolerance)) { |
| 190 | + if (!(event.originalEvent instanceof MouseEvent)) { |
195 | 191 | event.preventDefault(); |
196 | 192 | return; |
197 | 193 | } |
|
0 commit comments