Skip to content

Commit 93ce694

Browse files
committed
fixed #1659, fixed #1676
1 parent 30267af commit 93ce694

18 files changed

+156
-106
lines changed

demo/src/main/webapp/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!doctype html>
22
<html>
3-
<head>
3+
<head sytle="width:16000; height:16000">
44
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
55
<meta name="viewport" content="width=device-width">
66
<link type="text/css" rel="stylesheet" href="common.css">

demo/src/main/webapp/js/FileAPI.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/src/main/webapp/js/ng-file-upload-all.js

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* progress, resize, thumbnail, preview, validation and CORS
44
* FileAPI Flash shim for old browsers not supporting FormData
55
* @author Danial <danial.farid@gmail.com>
6-
* @version 12.2.4
6+
* @version 12.2.5
77
*/
88

99
(function () {
@@ -424,7 +424,7 @@ if (!window.FileReader) {
424424
* AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
425425
* progress, resize, thumbnail, preview, validation and CORS
426426
* @author Danial <danial.farid@gmail.com>
427-
* @version 12.2.4
427+
* @version 12.2.5
428428
*/
429429

430430
if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
@@ -445,7 +445,7 @@ if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
445445

446446
var ngFileUpload = angular.module('ngFileUpload', []);
447447

448-
ngFileUpload.version = '12.2.4';
448+
ngFileUpload.version = '12.2.5';
449449

450450
ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
451451
var upload = this;
@@ -1210,13 +1210,12 @@ ngFileUpload.directive('ngfSelect', ['$parse', '$timeout', '$compile', 'Upload',
12101210
return fileElem;
12111211
}
12121212

1213-
var initialTouchStartY = 0;
1214-
12151213
function clickHandler(evt) {
12161214
if (elem.attr('disabled')) return false;
12171215
if (attrGetter('ngfSelectDisabled', scope)) return;
12181216

1219-
var r = handleTouch(evt);
1217+
var r = detectSwipe(evt);
1218+
// prevent the click if it is a swipe
12201219
if (r != null) return r;
12211220

12221221
resetModel(evt);
@@ -1241,19 +1240,30 @@ ngFileUpload.directive('ngfSelect', ['$parse', '$timeout', '$compile', 'Upload',
12411240
return false;
12421241
}
12431242

1244-
function handleTouch(evt) {
1245-
var touches = evt.changedTouches || (evt.originalEvent && evt.originalEvent.changedTouches);
1246-
if (evt.type === 'touchstart') {
1247-
initialTouchStartY = touches ? touches[0].clientY : 0;
1248-
return true; // don't block event default
1249-
} else {
1250-
evt.stopPropagation();
1251-
evt.preventDefault();
12521243

1253-
// prevent scroll from triggering event
1254-
if (evt.type === 'touchend') {
1255-
var currentLocation = touches ? touches[0].clientY : 0;
1256-
if (Math.abs(currentLocation - initialTouchStartY) > 20) return false;
1244+
var initialTouchStartY = 0;
1245+
var initialTouchStartX = 0;
1246+
1247+
function detectSwipe(evt) {
1248+
var touches = evt.changedTouches || (evt.originalEvent && evt.originalEvent.changedTouches);
1249+
if (touches) {
1250+
if (evt.type === 'touchstart') {
1251+
initialTouchStartX = touches[0].clientX;
1252+
initialTouchStartY = touches[0].clientY;
1253+
return true; // don't block event default
1254+
} else {
1255+
// prevent scroll from triggering event
1256+
if (evt.type === 'touchend') {
1257+
var currentX = touches[0].clientX;
1258+
var currentY = touches[0].clientY;
1259+
if ((Math.abs(currentX - initialTouchStartX) > 20) ||
1260+
(Math.abs(currentY - initialTouchStartY) > 20)) {
1261+
evt.stopPropagation();
1262+
evt.preventDefault();
1263+
return false;
1264+
}
1265+
}
1266+
return true;
12571267
}
12581268
}
12591269
}

demo/src/main/webapp/js/ng-file-upload-all.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/src/main/webapp/js/ng-file-upload-shim.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* progress, resize, thumbnail, preview, validation and CORS
44
* FileAPI Flash shim for old browsers not supporting FormData
55
* @author Danial <danial.farid@gmail.com>
6-
* @version 12.2.4
6+
* @version 12.2.5
77
*/
88

99
(function () {

demo/src/main/webapp/js/ng-file-upload-shim.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/src/main/webapp/js/ng-file-upload.js

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
33
* progress, resize, thumbnail, preview, validation and CORS
44
* @author Danial <danial.farid@gmail.com>
5-
* @version 12.2.4
5+
* @version 12.2.5
66
*/
77

88
if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
@@ -23,7 +23,7 @@ if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
2323

2424
var ngFileUpload = angular.module('ngFileUpload', []);
2525

26-
ngFileUpload.version = '12.2.4';
26+
ngFileUpload.version = '12.2.5';
2727

2828
ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
2929
var upload = this;
@@ -788,13 +788,12 @@ ngFileUpload.directive('ngfSelect', ['$parse', '$timeout', '$compile', 'Upload',
788788
return fileElem;
789789
}
790790

791-
var initialTouchStartY = 0;
792-
793791
function clickHandler(evt) {
794792
if (elem.attr('disabled')) return false;
795793
if (attrGetter('ngfSelectDisabled', scope)) return;
796794

797-
var r = handleTouch(evt);
795+
var r = detectSwipe(evt);
796+
// prevent the click if it is a swipe
798797
if (r != null) return r;
799798

800799
resetModel(evt);
@@ -819,19 +818,30 @@ ngFileUpload.directive('ngfSelect', ['$parse', '$timeout', '$compile', 'Upload',
819818
return false;
820819
}
821820

822-
function handleTouch(evt) {
823-
var touches = evt.changedTouches || (evt.originalEvent && evt.originalEvent.changedTouches);
824-
if (evt.type === 'touchstart') {
825-
initialTouchStartY = touches ? touches[0].clientY : 0;
826-
return true; // don't block event default
827-
} else {
828-
evt.stopPropagation();
829-
evt.preventDefault();
830821

831-
// prevent scroll from triggering event
832-
if (evt.type === 'touchend') {
833-
var currentLocation = touches ? touches[0].clientY : 0;
834-
if (Math.abs(currentLocation - initialTouchStartY) > 20) return false;
822+
var initialTouchStartY = 0;
823+
var initialTouchStartX = 0;
824+
825+
function detectSwipe(evt) {
826+
var touches = evt.changedTouches || (evt.originalEvent && evt.originalEvent.changedTouches);
827+
if (touches) {
828+
if (evt.type === 'touchstart') {
829+
initialTouchStartX = touches[0].clientX;
830+
initialTouchStartY = touches[0].clientY;
831+
return true; // don't block event default
832+
} else {
833+
// prevent scroll from triggering event
834+
if (evt.type === 'touchend') {
835+
var currentX = touches[0].clientX;
836+
var currentY = touches[0].clientY;
837+
if ((Math.abs(currentX - initialTouchStartX) > 20) ||
838+
(Math.abs(currentY - initialTouchStartY) > 20)) {
839+
evt.stopPropagation();
840+
evt.preventDefault();
841+
return false;
842+
}
843+
}
844+
return true;
835845
}
836846
}
837847
}

demo/src/main/webapp/js/ng-file-upload.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/FileAPI.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ng-file-upload-all.js

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* progress, resize, thumbnail, preview, validation and CORS
44
* FileAPI Flash shim for old browsers not supporting FormData
55
* @author Danial <danial.farid@gmail.com>
6-
* @version 12.2.4
6+
* @version 12.2.5
77
*/
88

99
(function () {
@@ -424,7 +424,7 @@ if (!window.FileReader) {
424424
* AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
425425
* progress, resize, thumbnail, preview, validation and CORS
426426
* @author Danial <danial.farid@gmail.com>
427-
* @version 12.2.4
427+
* @version 12.2.5
428428
*/
429429

430430
if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
@@ -445,7 +445,7 @@ if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
445445

446446
var ngFileUpload = angular.module('ngFileUpload', []);
447447

448-
ngFileUpload.version = '12.2.4';
448+
ngFileUpload.version = '12.2.5';
449449

450450
ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
451451
var upload = this;
@@ -1210,13 +1210,12 @@ ngFileUpload.directive('ngfSelect', ['$parse', '$timeout', '$compile', 'Upload',
12101210
return fileElem;
12111211
}
12121212

1213-
var initialTouchStartY = 0;
1214-
12151213
function clickHandler(evt) {
12161214
if (elem.attr('disabled')) return false;
12171215
if (attrGetter('ngfSelectDisabled', scope)) return;
12181216

1219-
var r = handleTouch(evt);
1217+
var r = detectSwipe(evt);
1218+
// prevent the click if it is a swipe
12201219
if (r != null) return r;
12211220

12221221
resetModel(evt);
@@ -1241,19 +1240,30 @@ ngFileUpload.directive('ngfSelect', ['$parse', '$timeout', '$compile', 'Upload',
12411240
return false;
12421241
}
12431242

1244-
function handleTouch(evt) {
1245-
var touches = evt.changedTouches || (evt.originalEvent && evt.originalEvent.changedTouches);
1246-
if (evt.type === 'touchstart') {
1247-
initialTouchStartY = touches ? touches[0].clientY : 0;
1248-
return true; // don't block event default
1249-
} else {
1250-
evt.stopPropagation();
1251-
evt.preventDefault();
12521243

1253-
// prevent scroll from triggering event
1254-
if (evt.type === 'touchend') {
1255-
var currentLocation = touches ? touches[0].clientY : 0;
1256-
if (Math.abs(currentLocation - initialTouchStartY) > 20) return false;
1244+
var initialTouchStartY = 0;
1245+
var initialTouchStartX = 0;
1246+
1247+
function detectSwipe(evt) {
1248+
var touches = evt.changedTouches || (evt.originalEvent && evt.originalEvent.changedTouches);
1249+
if (touches) {
1250+
if (evt.type === 'touchstart') {
1251+
initialTouchStartX = touches[0].clientX;
1252+
initialTouchStartY = touches[0].clientY;
1253+
return true; // don't block event default
1254+
} else {
1255+
// prevent scroll from triggering event
1256+
if (evt.type === 'touchend') {
1257+
var currentX = touches[0].clientX;
1258+
var currentY = touches[0].clientY;
1259+
if ((Math.abs(currentX - initialTouchStartX) > 20) ||
1260+
(Math.abs(currentY - initialTouchStartY) > 20)) {
1261+
evt.stopPropagation();
1262+
evt.preventDefault();
1263+
return false;
1264+
}
1265+
}
1266+
return true;
12571267
}
12581268
}
12591269
}

0 commit comments

Comments
 (0)