Skip to content

Commit 193a6eb

Browse files
distribution updated
1 parent 441b85e commit 193a6eb

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

dist/jquery.bxslider.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,11 +1091,16 @@
10911091
* - DOM event object
10921092
*/
10931093
var onTouchStart = function(e) {
1094+
// watch only for left mouse, touch contact and pen contact
1095+
// touchstart event object doesn`t have button property
1096+
if (e.type !== 'touchstart' && e.button !== 0) {
1097+
return;
1098+
}
1099+
e.preventDefault();
10941100
//disable slider controls while user is interacting with slides to avoid slider freeze that happens on touch devices when a slide swipe happens immediately after interacting with slider controls
10951101
slider.controls.el.addClass('disabled');
10961102

10971103
if (slider.working) {
1098-
e.preventDefault();
10991104
slider.controls.el.removeClass('disabled');
11001105
} else {
11011106
// record the original position when touch starts
@@ -1110,6 +1115,13 @@
11101115
slider.pointerId = orig.pointerId;
11111116
slider.viewport.get(0).setPointerCapture(slider.pointerId);
11121117
}
1118+
// store original event data for click fixation
1119+
slider.originalClickTarget = orig.originalTarget;
1120+
slider.originalClickButton = orig.button;
1121+
slider.originalClickButtons = orig.buttons;
1122+
slider.originalEventType = orig.type;
1123+
// at this moment we don`t know what it is click or swipe
1124+
slider.hasMove = false;
11131125
// bind a "touchmove" event to the viewport
11141126
slider.viewport.bind('touchmove MSPointerMove pointermove', onTouchMove);
11151127
// bind a "touchend" event to the viewport
@@ -1125,6 +1137,7 @@
11251137
* - DOM event object
11261138
*/
11271139
var onPointerCancel = function(e) {
1140+
e.preventDefault();
11281141
/* onPointerCancel handler is needed to deal with situations when a touchend
11291142
doesn't fire after a touchstart (this happens on windows phones only) */
11301143
setPositionProperty(slider.touch.originalPos.left, 'reset', 0);
@@ -1153,6 +1166,8 @@
11531166
yMovement = Math.abs(touchPoints[0].pageY - slider.touch.start.y),
11541167
value = 0,
11551168
change = 0;
1169+
// this is swipe
1170+
slider.hasMove = true;
11561171

11571172
// x axis swipe
11581173
if ((xMovement * 3) > yMovement && slider.settings.preventDefaultSwipeX) {
@@ -1161,6 +1176,10 @@
11611176
} else if ((yMovement * 3) > xMovement && slider.settings.preventDefaultSwipeY) {
11621177
e.preventDefault();
11631178
}
1179+
if (e.type !== 'touchmove') {
1180+
e.preventDefault();
1181+
}
1182+
11641183
if (slider.settings.mode !== 'fade' && slider.settings.oneToOneTouch) {
11651184
// if horizontal, drag along x axis
11661185
if (slider.settings.mode === 'horizontal') {
@@ -1182,6 +1201,7 @@
11821201
* - DOM event object
11831202
*/
11841203
var onTouchEnd = function(e) {
1204+
e.preventDefault();
11851205
slider.viewport.unbind('touchmove MSPointerMove pointermove', onTouchMove);
11861206
//enable slider controls as soon as user stops interacing with slides
11871207
slider.controls.el.removeClass('disabled');
@@ -1232,9 +1252,19 @@
12321252
}
12331253
}
12341254
slider.viewport.unbind('touchend MSPointerUp pointerup', onTouchEnd);
1255+
12351256
if (slider.viewport.get(0).releasePointerCapture) {
12361257
slider.viewport.get(0).releasePointerCapture(slider.pointerId);
12371258
}
1259+
// if slider had swipe with left mouse, touch contact and pen contact
1260+
if (slider.hasMove === false && (slider.originalClickButton === 0 || slider.originalEventType === 'touchstart')) {
1261+
// trigger click event (fix for Firefox59 and PointerEvent standard compatibility)
1262+
$(slider.originalClickTarget).trigger({
1263+
type: 'click',
1264+
button: slider.originalClickButton,
1265+
buttons: slider.originalClickButtons
1266+
});
1267+
}
12381268
};
12391269

12401270
/**

0 commit comments

Comments
 (0)