Skip to content

Commit

Permalink
Cannot read property '0' of undefined alirezamirian#9
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Maurer committed Nov 7, 2017
1 parent 7c18185 commit f6c841f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
21 changes: 11 additions & 10 deletions dist/mde-swipe-to-refresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* https://github.com/alirezamirian/angular-material-swipe-to-refresh
*/



(function(angular){
"use strict";
angular.module("mde.swipeToRefresh", [])
Expand Down Expand Up @@ -42,6 +40,13 @@
link: linkFn
};

function getEvent(event) {
if (angular.isDefined(event.originalEvent)) {
return event.originalEvent;
}
return event;
}

function linkFn(scope, elem, attrs, mdeSwipeToRefreshScrollHost){
elem.bind("touchstart", touchStart);
var scrollHost, startY;
Expand Down Expand Up @@ -75,7 +80,7 @@
if(scope.state != State.None){
return;
}
startY = event.touches[0].pageY;
startY = getEvent(event).touches[0].pageY;
elem.one("touchend", touchEnd);
elem.bind("touchmove", touchMove);

Expand All @@ -90,10 +95,10 @@
if(scrollHost[0].scrollTop > 0){
return;
}
var movement = event.touches[0].pageY - startY;
var movement = getEvent(event).touches[0].pageY - startY;

if(movement > 0 && scope.state != State.Pulling){
startY = event.touches[0].pageY;
startY = getEvent(event).touches[0].pageY;
movement = 0;
scope.state = State.Pulling;
}
Expand Down Expand Up @@ -142,16 +147,14 @@
}
}
function calculateMovement(movement, activationThreshold) {

return 2 * activationThreshold * log10((movement + activationThreshold) / activationThreshold);
return 2 * activationThreshold * log10((movement + activationThreshold) / activationThreshold);
}
function log10(x){
return Math.log(x)/Math.LN10;
// we don't use Math.log10 as it's only available in ES6
}
})(angular);


(function(angular){
"use strict";
angular.module('mde.swipeToRefresh')
Expand All @@ -175,8 +178,6 @@

})(angular);



// source: https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
if (!Element.prototype.matches) {
Element.prototype.matches =
Expand Down
2 changes: 1 addition & 1 deletion dist/mde-swipe-to-refresh.min.js

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

13 changes: 10 additions & 3 deletions src/swipe-to-refresh/swipe-to-refresh.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
link: linkFn
};

function getEvent(event) {
if (angular.isDefined(event.originalEvent)) {
return event.originalEvent;
}
return event;
}

function linkFn(scope, elem, attrs, mdeSwipeToRefreshScrollHost){
elem.bind("touchstart", touchStart);
var scrollHost, startY;
Expand Down Expand Up @@ -58,7 +65,7 @@
if(scope.state != State.None){
return;
}
startY = event.originalEvent.touches[0].pageY;
startY = getEvent(event).touches[0].pageY;
elem.one("touchend", touchEnd);
elem.bind("touchmove", touchMove);

Expand All @@ -73,10 +80,10 @@
if(scrollHost[0].scrollTop > 0){
return;
}
var movement = event.originalEvent.touches[0].pageY - startY;
var movement = getEvent(event).touches[0].pageY - startY;

if(movement > 0 && scope.state != State.Pulling){
startY = event.originalEvent.touches[0].pageY;
startY = getEvent(event).touches[0].pageY;
movement = 0;
scope.state = State.Pulling;
}
Expand Down

0 comments on commit f6c841f

Please sign in to comment.