Skip to content

Commit

Permalink
Patched cubiq/iscroll cubiq#20. [pull down to refresh] pullToRefresh …
Browse files Browse the repository at this point in the history
…div is displayed initially.
  • Loading branch information
thomasyip committed Mar 7, 2011
1 parent 670368c commit fc2b1d6
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions src/iscroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ function iScroll (el, options) {
div.innerHTML = '<span class="iScrollPullDownIcon"></span><span class="iScrollPullDownLabel">' + that.options.pullDownLabel[0] + '</span>\n';
that.scroller.insertBefore(div, that.scroller.children[0]);
that.options.bounce = true;
that.offsetBottom = div.offsetHeight;
that.scroller.style.marginTop = -that.offsetBottom + 'px';
that.pullDownEl = div;
that.pullDownLabel = div.getElementsByTagName('span')[1];
}
Expand All @@ -95,8 +93,6 @@ function iScroll (el, options) {
div.innerHTML = '<span class="iScrollPullUpIcon"></span><span class="iScrollPullUpLabel">' + that.options.pullUpLabel[0] + '</span>\n';
that.scroller.appendChild(div);
that.options.bounce = true;
that.offsetTop = div.offsetHeight;
that.scroller.style.marginBottom = -that.offsetTop + 'px';
that.pullUpEl = div;
that.pullUpLabel = div.getElementsByTagName('span')[1];
}
Expand Down Expand Up @@ -299,7 +295,7 @@ iScroll.prototype = {
matrix = window.getComputedStyle(that.scroller, null);
if (that.x + 'px' != matrix.left || that.y + 'px' != matrix.top) {
that._unbind('webkitTransitionEnd');
that._pos(matrix.left.replace(/[^0-9]/g)*1, matrix.top.replace(/[^0-9]/g)*1)
that._pos(matrix.left.replace(/[^0-9]/g)*1, matrix.top.replace(/[^0-9]/g)*1);
}
}

Expand Down Expand Up @@ -706,7 +702,7 @@ iScroll.prototype = {
that.refresh();
}, 0);

that._bind('gesturestart')
that._bind('gesturestart');
that._unbind('gesturechange');
that._unbind('gestureend');
that._unbind('gesturecancel');
Expand Down Expand Up @@ -817,7 +813,7 @@ iScroll.prototype = {
that._unbind(CANCEL_EV);

if (that.options.zoom) {
that._unbind('gesturestart')
that._unbind('gesturestart');
that._unbind('gesturechange');
that._unbind('gestureend');
that._unbind('gesturecancel');
Expand All @@ -830,25 +826,36 @@ iScroll.prototype = {
i, l, els,
oldHeight, offsets;

if (that.pullDownToRefresh && that.pullDownEl.className.match('loading') && !that.contentReady) {
oldHeight = that.scrollerH;
that.contentReady = true;
that.pullDownEl.className = 'iScrollPullDown';
that.pullDownLabel.innerText = that.options.pullDownLabel[0];
that.offsetBottom = that.pullDownEl.offsetHeight;
that.scroller.style.marginTop = -that.offsetBottom + 'px';
if (that.pullDownToRefresh) {
var loading = that.pullDownEl.className.match('loading');
if (loading && !that.contentReady) {
oldHeight = that.scrollerH;
that.contentReady = true;
that.pullDownEl.className = 'iScrollPullDown';
that.pullDownLabel.innerText = that.options.pullDownLabel[0];
that.offsetBottom = that.pullDownEl.offsetHeight;
that.scroller.style.marginTop = -that.offsetBottom + 'px';
} else if (!loading) {
that.offsetBottom = that.pullDownEl.offsetHeight;
that.scroller.style.marginTop = -that.offsetBottom + 'px';
}
}

if (that.pullUpToRefresh && that.pullUpEl.className.match('loading') && !that.contentReady) {
oldHeight = that.scrollerH;
that.contentReady = true;
that.pullUpEl.className = 'iScrollPullUp';
that.pullUpLabel.innerText = that.options.pullUpLabel[0];
that.offsetTop = that.pullUpEl.offsetHeight;
that.scroller.style.marginBottom = -that.offsetTop + 'px';
if (that.pullUpToRefresh) {
var loading = that.pullUpEl.className.match('loading');
if (loading && !that.contentReady) {
oldHeight = that.scrollerH;
that.contentReady = true;
that.pullUpEl.className = 'iScrollPullUp';
that.pullUpLabel.innerText = that.options.pullUpLabel[0];
that.offsetTop = that.pullUpEl.offsetHeight;
that.scroller.style.marginBottom = -that.offsetTop + 'px';
} else if (!loading) {
that.offsetTop = that.pullUpEl.offsetHeight;
that.scroller.style.marginBottom = -that.offsetTop + 'px';
}
}


that.wrapperW = that.wrapper.clientWidth;
that.wrapperH = that.wrapper.clientHeight;
that.scrollerW = m.round(that.scroller.offsetWidth * that.scale);
Expand Down Expand Up @@ -991,7 +998,7 @@ iScroll.prototype = {
that.zoomed = true;
that.scroller.style.webkitTransform = trnOpen + that.x + 'px,' + that.y + 'px' + trnClose + ' scale(' + scale + ')';
}, 0);
},
}
};


Expand Down

0 comments on commit fc2b1d6

Please sign in to comment.