Skip to content

Commit

Permalink
#282 - Larger pull threshold for refresh.
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf committed Sep 15, 2020
1 parent 55b9514 commit aa7b300
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/Money.Blazor.Host/wwwroot/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ window.PullToRefresh = {
Initialize: function (interop) {
window.PullToRefresh._interop = interop;

const refreshTreshold = 200;
let _isActive = false;
let _startY;
let _maxY = 0;
let container = document.body;
const listenerOptions = { passive: true };

container.addEventListener('touchstart', e => {
_startY = 0;
Expand All @@ -82,20 +84,19 @@ window.PullToRefresh = {
} else {
_isActive = false;
}
}, { passive: true });
}, listenerOptions);

container.addEventListener('touchmove', e => {
const y = e.touches[0].pageY;
_maxY = Math.floor(y);
}, { passive: true });
}, listenerOptions);

container.addEventListener("touchend", () => {
const delta = Math.floor(_maxY - _startY);
if (_isActive && delta > 100) {
//alert(`Start '${_startY}', Max '${_maxY}', Delta '${delta}'`);
if (_isActive && delta > refreshTreshold) {
window.PullToRefresh.Raise();
}
}, { passive: true });
}, listenerOptions);
},
Raise: function() {
window.PullToRefresh._interop.invokeMethodAsync("PullToRefresh.Pulled");
Expand Down
2 changes: 1 addition & 1 deletion src/Money.Blazor.Host/wwwroot/js/site.min.js

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

0 comments on commit aa7b300

Please sign in to comment.