From 092d4b7b42ff835e063b76961baa41bf8f991671 Mon Sep 17 00:00:00 2001 From: Christoph Maurer Date: Thu, 9 Nov 2017 11:20:36 +0100 Subject: [PATCH] #11 scroll up from bottom of the page bugfix --- dist/mde-swipe-to-refresh.js | 6 +----- dist/mde-swipe-to-refresh.min.js | 2 +- src/swipe-to-refresh/swipe-to-refresh.directive.js | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/dist/mde-swipe-to-refresh.js b/dist/mde-swipe-to-refresh.js index 422d1b7..ebdb80e 100644 --- a/dist/mde-swipe-to-refresh.js +++ b/dist/mde-swipe-to-refresh.js @@ -103,11 +103,7 @@ scope.state = State.Pulling; } - if(scope.state == State.Pulling){ - event.preventDefault(); - } - - if(movement > 0){ + if(movement > 0){ scope.movement = Math.min(calculateMovement(movement, scope.mdeThreshold)); scope.progress = Math.min( scope.movement/scope.mdeThreshold, 1); scope.$digest(); diff --git a/dist/mde-swipe-to-refresh.min.js b/dist/mde-swipe-to-refresh.min.js index 05c36a0..d28afd9 100644 --- a/dist/mde-swipe-to-refresh.min.js +++ b/dist/mde-swipe-to-refresh.min.js @@ -4,4 +4,4 @@ * https://github.com/alirezamirian/angular-material-swipe-to-refresh */ -!function(e){"use strict";e.module("mde.swipeToRefresh",[]).constant("mdeSwipeToRefreshConfig",{threshold:80})}(angular),function(e){"use strict";function t(t,o,s){function i(t){return e.isDefined(t.originalEvent)?t.originalEvent:t}function l(l,a,m,c){function d(e){l.state==r.None&&(g=i(e).touches[0].pageY,a.one("touchend",p),a.bind("touchmove",u),0==h[0].scrollTop&&(l.progress=0,l.movement=0,l.$digest()))}function u(e){if(!(h[0].scrollTop>0)){var t=i(e).touches[0].pageY-g;t>0&&l.state!=r.Pulling&&(g=i(e).touches[0].pageY,t=0,l.state=r.Pulling),l.state==r.Pulling&&e.preventDefault(),t>0?(l.movement=Math.min(n(t,l.mdeThreshold)),l.progress=Math.min(l.movement/l.mdeThreshold,1),l.$digest()):l.movement>0&&(l.movement=0,l.progress=0,l.$digest())}}function p(n){a.unbind("touchmove",u),l.$apply(function(){1==l.progress?(l.state=r.Updating,l.movement=l.mdeThreshold,t.when((l.mdeOnRefresh||e.noop)())["finally"](function(){l.state=r.None,l.movement=0,l.progress=0})):(l.movement>0&&((l.mdeOnCancel||e.noop)(),l.movement=0,l.progress=0),o(function(){l.state=r.None},100))})}a.bind("touchstart",d);var h,g;if(c)h=c.getElement();else if(l.mdeScrollHostSelector){for(var f=a.parent();f[0]!=document.body;)if(f=f.parent(),f[0].matches(l.mdeScrollHostSelector)){h=f;break}h=h||f}else h=e.element(document.body);l.mdeThreshold=l.mdeThreshold||s.threshold,l.State=r,l.progress=0,l.state=r.None}return{restrict:"A",require:"?^mdeSwipeToRefreshScrollHost",transclude:!0,scope:{mdeOnRefresh:"&?",mdeOnCancel:"&?",mdeScrollHostSelector:"@?",mdeThreshold:"=?"},templateUrl:"swipe-to-refresh/swipe-to-refresh.html",link:l}}function n(e,t){return 2*t*o((e+t)/t)}function o(e){return Math.log(e)/Math.LN10}t.$inject=["$q","$timeout","mdeSwipeToRefreshConfig"],e.module("mde.swipeToRefresh").directive("mdeSwipeToRefresh",t);var r={None:"None",Updating:"Updating",Pulling:"Pulling"}}(angular),function(e){"use strict";function t(){function e(e){function t(){return e}this.getElement=t}return e.$inject=["$element"],{restrict:"A",controller:e}}e.module("mde.swipeToRefresh").directive("mdeSwipeToRefreshScrollHost",t)}(angular),Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),n=t.length;--n>=0&&t.item(n)!==this;);return n>-1}),function(e){try{e=angular.module("mde.swipeToRefresh")}catch(t){e=angular.module("mde.swipeToRefresh",[])}e.run(["$templateCache",function(e){e.put("swipe-to-refresh/swipe-to-refresh.html",'\n \n \n \n \n \n \n \n \n\n
\n')}])}(); \ No newline at end of file +!function(e){"use strict";e.module("mde.swipeToRefresh",[]).constant("mdeSwipeToRefreshConfig",{threshold:80})}(angular),function(e){"use strict";function t(t,o,s){function i(t){return e.isDefined(t.originalEvent)?t.originalEvent:t}function l(l,m,a,c){function d(e){l.state==r.None&&(g=i(e).touches[0].pageY,m.one("touchend",p),m.bind("touchmove",u),0==h[0].scrollTop&&(l.progress=0,l.movement=0,l.$digest()))}function u(e){if(!(h[0].scrollTop>0)){var t=i(e).touches[0].pageY-g;t>0&&l.state!=r.Pulling&&(g=i(e).touches[0].pageY,t=0,l.state=r.Pulling),t>0?(l.movement=Math.min(n(t,l.mdeThreshold)),l.progress=Math.min(l.movement/l.mdeThreshold,1),l.$digest()):l.movement>0&&(l.movement=0,l.progress=0,l.$digest())}}function p(n){m.unbind("touchmove",u),l.$apply(function(){1==l.progress?(l.state=r.Updating,l.movement=l.mdeThreshold,t.when((l.mdeOnRefresh||e.noop)())["finally"](function(){l.state=r.None,l.movement=0,l.progress=0})):(l.movement>0&&((l.mdeOnCancel||e.noop)(),l.movement=0,l.progress=0),o(function(){l.state=r.None},100))})}m.bind("touchstart",d);var h,g;if(c)h=c.getElement();else if(l.mdeScrollHostSelector){for(var f=m.parent();f[0]!=document.body;)if(f=f.parent(),f[0].matches(l.mdeScrollHostSelector)){h=f;break}h=h||f}else h=e.element(document.body);l.mdeThreshold=l.mdeThreshold||s.threshold,l.State=r,l.progress=0,l.state=r.None}return{restrict:"A",require:"?^mdeSwipeToRefreshScrollHost",transclude:!0,scope:{mdeOnRefresh:"&?",mdeOnCancel:"&?",mdeScrollHostSelector:"@?",mdeThreshold:"=?"},templateUrl:"swipe-to-refresh/swipe-to-refresh.html",link:l}}function n(e,t){return 2*t*o((e+t)/t)}function o(e){return Math.log(e)/Math.LN10}t.$inject=["$q","$timeout","mdeSwipeToRefreshConfig"],e.module("mde.swipeToRefresh").directive("mdeSwipeToRefresh",t);var r={None:"None",Updating:"Updating",Pulling:"Pulling"}}(angular),function(e){"use strict";function t(){function e(e){function t(){return e}this.getElement=t}return e.$inject=["$element"],{restrict:"A",controller:e}}e.module("mde.swipeToRefresh").directive("mdeSwipeToRefreshScrollHost",t)}(angular),Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),n=t.length;--n>=0&&t.item(n)!==this;);return n>-1}),function(e){try{e=angular.module("mde.swipeToRefresh")}catch(t){e=angular.module("mde.swipeToRefresh",[])}e.run(["$templateCache",function(e){e.put("swipe-to-refresh/swipe-to-refresh.html",'\n \n \n \n \n \n \n \n \n\n
\n')}])}(); \ No newline at end of file diff --git a/src/swipe-to-refresh/swipe-to-refresh.directive.js b/src/swipe-to-refresh/swipe-to-refresh.directive.js index 86b32ef..81d49e6 100644 --- a/src/swipe-to-refresh/swipe-to-refresh.directive.js +++ b/src/swipe-to-refresh/swipe-to-refresh.directive.js @@ -88,9 +88,9 @@ scope.state = State.Pulling; } - if(scope.state == State.Pulling){ + /*if(scope.state == State.Pulling){ event.preventDefault(); - } + }*/ if(movement > 0){ scope.movement = Math.min(calculateMovement(movement, scope.mdeThreshold));