On refresh opening

This commit is contained in:
Max Lynch
2013-11-08 15:44:22 -06:00
parent 8a7db90aaf
commit 7c4a37e56a
6 changed files with 84 additions and 71 deletions

View File

@ -29,40 +29,6 @@
toiletSeat: 'cubic-bezier(0.05, 0.60, 0.05, 0.60)'
};
/**
* The Pull To Refresh drag operation handles the well-known
* "pull to refresh" concept seen on various apps. This lets
* the user indicate they want to refresh a given list by dragging
* down.
*
* @param {object} opts the options for the pull to refresh drag.
*/
/*
var PullToRefreshDrag = function(opts) {
this.dragThresholdY = opts.dragThresholdY || 10;
this.onRefreshOpening = opts.onRefreshOpening || function() {};
this.onRefresh = opts.onRefresh || function() {};
this.onRefreshHolding = opts.onRefreshHolding || function() {};
this.el = opts.el;
};
PullToRefreshDrag.prototype.end = function(e, doneCallback) {
if(currentHeight > firstChildHeight) {
//this.refreshing();
} else {
// Enable animations
refresher.classList.add('list-refreshing');
refresher.style.height = '0px';
this.onRefresh && _this.onRefresh();
}
this._currentDrag = null;
doneCallback && doneCallback();
};
*/
ionic.views.Scroll = ionic.views.View.inherit({
initialize: function(opts) {
@ -89,6 +55,7 @@
refreshEasing: EASING_FUNCTIONS.bounce,
// ms transition time
refreshEasingTime: 400,
refreshOpeningInterval: 100,
// How frequently to fire scroll events in the case of
// a flick or momentum scroll where the finger is no longer
@ -125,6 +92,13 @@
this.y = 0;
this.x = 0;
// Create a throttled pull to refresh "opening" function
// which will get called as the refresh "opens" from drag
var refreshOpening = _this.onRefreshOpening;
_this.onRefreshOpening = ionic.throttle(function(ratio) {
refreshOpening && refreshOpening(ratio);
}, 100);
// Listen for drag and release events
ionic.onGesture('drag', function(e) {
_this._handleDrag(e);
@ -624,7 +598,7 @@
} else {
// Trigger refresh open amount
var ratio = Math.min(1, newY / _this._refresherHeight);
_this.onRefreshOpening && _this.onRefreshOpening(ratio);
_this.onRefreshOpening(ratio);
}
// Update the new translated Y point of the container