Skip to content

Commit

Permalink
distribution updated
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmenhuseyin committed Apr 9, 2018
1 parent 441b85e commit 193a6eb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
32 changes: 31 additions & 1 deletion dist/jquery.bxslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -1091,11 +1091,16 @@
* - DOM event object
*/
var onTouchStart = function(e) {
// watch only for left mouse, touch contact and pen contact
// touchstart event object doesn`t have button property
if (e.type !== 'touchstart' && e.button !== 0) {
return;
}
e.preventDefault();
//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
slider.controls.el.addClass('disabled');

if (slider.working) {
e.preventDefault();
slider.controls.el.removeClass('disabled');
} else {
// record the original position when touch starts
Expand All @@ -1110,6 +1115,13 @@
slider.pointerId = orig.pointerId;
slider.viewport.get(0).setPointerCapture(slider.pointerId);
}
// store original event data for click fixation
slider.originalClickTarget = orig.originalTarget;
slider.originalClickButton = orig.button;
slider.originalClickButtons = orig.buttons;
slider.originalEventType = orig.type;
// at this moment we don`t know what it is click or swipe
slider.hasMove = false;
// bind a "touchmove" event to the viewport
slider.viewport.bind('touchmove MSPointerMove pointermove', onTouchMove);
// bind a "touchend" event to the viewport
Expand All @@ -1125,6 +1137,7 @@
* - DOM event object
*/
var onPointerCancel = function(e) {
e.preventDefault();
/* onPointerCancel handler is needed to deal with situations when a touchend
doesn't fire after a touchstart (this happens on windows phones only) */
setPositionProperty(slider.touch.originalPos.left, 'reset', 0);
Expand Down Expand Up @@ -1153,6 +1166,8 @@
yMovement = Math.abs(touchPoints[0].pageY - slider.touch.start.y),
value = 0,
change = 0;
// this is swipe
slider.hasMove = true;

// x axis swipe
if ((xMovement * 3) > yMovement && slider.settings.preventDefaultSwipeX) {
Expand All @@ -1161,6 +1176,10 @@
} else if ((yMovement * 3) > xMovement && slider.settings.preventDefaultSwipeY) {
e.preventDefault();
}
if (e.type !== 'touchmove') {
e.preventDefault();
}

if (slider.settings.mode !== 'fade' && slider.settings.oneToOneTouch) {
// if horizontal, drag along x axis
if (slider.settings.mode === 'horizontal') {
Expand All @@ -1182,6 +1201,7 @@
* - DOM event object
*/
var onTouchEnd = function(e) {
e.preventDefault();
slider.viewport.unbind('touchmove MSPointerMove pointermove', onTouchMove);
//enable slider controls as soon as user stops interacing with slides
slider.controls.el.removeClass('disabled');
Expand Down Expand Up @@ -1232,9 +1252,19 @@
}
}
slider.viewport.unbind('touchend MSPointerUp pointerup', onTouchEnd);

if (slider.viewport.get(0).releasePointerCapture) {
slider.viewport.get(0).releasePointerCapture(slider.pointerId);
}
// if slider had swipe with left mouse, touch contact and pen contact
if (slider.hasMove === false && (slider.originalClickButton === 0 || slider.originalEventType === 'touchstart')) {
// trigger click event (fix for Firefox59 and PointerEvent standard compatibility)
$(slider.originalClickTarget).trigger({
type: 'click',
button: slider.originalClickButton,
buttons: slider.originalClickButtons
});
}
};

/**
Expand Down
Loading

0 comments on commit 193a6eb

Please sign in to comment.