Skip to content

Commit

Permalink
fix swipe on mobile devices
Browse files Browse the repository at this point in the history
  • Loading branch information
snake-345 committed Mar 4, 2016
1 parent db549ef commit aa2612e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jcarouselSwipe",
"main": "./dist/jquery.jcarousel-swipe.js",
"version": "0.3.1",
"version": "0.3.2",
"authors": [
"Evgeniy Pelmenev <[email protected]>"
],
Expand Down
10 changes: 8 additions & 2 deletions dist/jquery.jcarousel-swipe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! jсarouselSwipe - v0.3.1 - 2016-02-18
/*! jсarouselSwipe - v0.3.2 - 2016-02-18
* Copyright (c) 2015 Evgeniy Pelmenev; Licensed MIT */
(function($) {
'use strict';
Expand Down Expand Up @@ -88,6 +88,7 @@
}

function dragEnd(event) {
console.log(event);
event = event.originalEvent || event || window.event;
currentTouch = getTouches(event);
if (started || (!self._options.draggable && Math.abs(startTouch[xKey] - currentTouch[xKey]) > 10)) {
Expand Down Expand Up @@ -124,11 +125,16 @@
}

function getTouches(event) {
if (event.touches !== undefined) {
if (event.touches !== undefined && event.touches.length > 0) {
return {
x: event.touches[0].pageX,
y: event.touches[0].pageY
}
} else if (event.changedTouches !== undefined && event.changedTouches.length > 0) {
return {
x: event.changedTouches[0].pageX,
y: event.changedTouches[0].pageY
}
} else {
if (event.pageX !== undefined) {
return {
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.jcarousel-swipe.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jcarouselSwipe",
"version": "0.3.1",
"version": "0.3.2",
"description": "Adds comfortable swipe gestures to jcarousel",
"author": "Evgeniy Pelmenev <[email protected]>",
"license": "MIT",
Expand Down
10 changes: 8 additions & 2 deletions src/jquery.jcarousel-swipe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! jсarouselSwipe - v0.3.1 - 2016-02-18
/*! jсarouselSwipe - v0.3.2 - 2016-02-18
* Copyright (c) 2015 Evgeniy Pelmenev; Licensed MIT */
(function($) {
'use strict';
Expand Down Expand Up @@ -88,6 +88,7 @@
}

function dragEnd(event) {
console.log(event);
event = event.originalEvent || event || window.event;
currentTouch = getTouches(event);
if (started || (!self._options.draggable && Math.abs(startTouch[xKey] - currentTouch[xKey]) > 10)) {
Expand Down Expand Up @@ -124,11 +125,16 @@
}

function getTouches(event) {
if (event.touches !== undefined) {
if (event.touches !== undefined && event.touches.length > 0) {
return {
x: event.touches[0].pageX,
y: event.touches[0].pageY
}
} else if (event.changedTouches !== undefined && event.changedTouches.length > 0) {
return {
x: event.changedTouches[0].pageX,
y: event.changedTouches[0].pageY
}
} else {
if (event.pageX !== undefined) {
return {
Expand Down

0 comments on commit aa2612e

Please sign in to comment.