Skip to content

Commit

Permalink
12.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
danialfarid committed Aug 26, 2016
1 parent f04c594 commit 95e35f1
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular:[email protected]
danialf:[email protected].3
danialf:[email protected].4
[email protected]
[email protected]
2 changes: 1 addition & 1 deletion FileAPI.min.js

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

46 changes: 28 additions & 18 deletions ng-file-upload-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* progress, resize, thumbnail, preview, validation and CORS
* FileAPI Flash shim for old browsers not supporting FormData
* @author Danial <[email protected]>
* @version 12.2.4
* @version 12.2.5
*/

(function () {
Expand Down Expand Up @@ -424,7 +424,7 @@ if (!window.FileReader) {
* AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
* progress, resize, thumbnail, preview, validation and CORS
* @author Danial <[email protected]>
* @version 12.2.4
* @version 12.2.5
*/

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

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

ngFileUpload.version = '12.2.4';
ngFileUpload.version = '12.2.5';

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

var initialTouchStartY = 0;

function clickHandler(evt) {
if (elem.attr('disabled')) return false;
if (attrGetter('ngfSelectDisabled', scope)) return;

var r = handleTouch(evt);
var r = detectSwipe(evt);
// prevent the click if it is a swipe
if (r != null) return r;

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

function handleTouch(evt) {
var touches = evt.changedTouches || (evt.originalEvent && evt.originalEvent.changedTouches);
if (evt.type === 'touchstart') {
initialTouchStartY = touches ? touches[0].clientY : 0;
return true; // don't block event default
} else {
evt.stopPropagation();
evt.preventDefault();

// prevent scroll from triggering event
if (evt.type === 'touchend') {
var currentLocation = touches ? touches[0].clientY : 0;
if (Math.abs(currentLocation - initialTouchStartY) > 20) return false;
var initialTouchStartY = 0;
var initialTouchStartX = 0;

function detectSwipe(evt) {
var touches = evt.changedTouches || (evt.originalEvent && evt.originalEvent.changedTouches);
if (touches) {
if (evt.type === 'touchstart') {
initialTouchStartX = touches[0].clientX;
initialTouchStartY = touches[0].clientY;
return true; // don't block event default
} else {
// prevent scroll from triggering event
if (evt.type === 'touchend') {
var currentX = touches[0].clientX;
var currentY = touches[0].clientY;
if ((Math.abs(currentX - initialTouchStartX) > 20) ||
(Math.abs(currentY - initialTouchStartY) > 20)) {
evt.stopPropagation();
evt.preventDefault();
return false;
}
}
return true;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions ng-file-upload-all.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ng-file-upload-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* progress, resize, thumbnail, preview, validation and CORS
* FileAPI Flash shim for old browsers not supporting FormData
* @author Danial <[email protected]>
* @version 12.2.4
* @version 12.2.5
*/

(function () {
Expand Down
2 changes: 1 addition & 1 deletion ng-file-upload-shim.min.js

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

44 changes: 27 additions & 17 deletions ng-file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
* progress, resize, thumbnail, preview, validation and CORS
* @author Danial <[email protected]>
* @version 12.2.4
* @version 12.2.5
*/

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

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

ngFileUpload.version = '12.2.4';
ngFileUpload.version = '12.2.5';

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

var initialTouchStartY = 0;

function clickHandler(evt) {
if (elem.attr('disabled')) return false;
if (attrGetter('ngfSelectDisabled', scope)) return;

var r = handleTouch(evt);
var r = detectSwipe(evt);
// prevent the click if it is a swipe
if (r != null) return r;

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

function handleTouch(evt) {
var touches = evt.changedTouches || (evt.originalEvent && evt.originalEvent.changedTouches);
if (evt.type === 'touchstart') {
initialTouchStartY = touches ? touches[0].clientY : 0;
return true; // don't block event default
} else {
evt.stopPropagation();
evt.preventDefault();

// prevent scroll from triggering event
if (evt.type === 'touchend') {
var currentLocation = touches ? touches[0].clientY : 0;
if (Math.abs(currentLocation - initialTouchStartY) > 20) return false;
var initialTouchStartY = 0;
var initialTouchStartX = 0;

function detectSwipe(evt) {
var touches = evt.changedTouches || (evt.originalEvent && evt.originalEvent.changedTouches);
if (touches) {
if (evt.type === 'touchstart') {
initialTouchStartX = touches[0].clientX;
initialTouchStartY = touches[0].clientY;
return true; // don't block event default
} else {
// prevent scroll from triggering event
if (evt.type === 'touchend') {
var currentX = touches[0].clientX;
var currentY = touches[0].clientY;
if ((Math.abs(currentX - initialTouchStartX) > 20) ||
(Math.abs(currentY - initialTouchStartY) > 20)) {
evt.stopPropagation();
evt.preventDefault();
return false;
}
}
return true;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions ng-file-upload.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: "danialf:ng-file-upload",
"version": "12.2.4",
"version": "12.2.5",
summary: "Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support",
git: "https://github.com/danialfarid/ng-file-upload.git"
});
Expand Down

0 comments on commit 95e35f1

Please sign in to comment.