Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Spinelli committed Sep 22, 2011
1 parent 82b4f3b commit 8165866
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 23 deletions.
3 changes: 2 additions & 1 deletion README.md
@@ -1,4 +1,4 @@
iScroll v4.1.9 - 2011-08-03
iScroll v4.1.9 - 2011-09-22
===========================

The overflow:scroll for mobile webkit. Project started because webkit for iPhone does not provide a native way to scroll content inside a fixed size (width/height) div. So basically it was impossible to have a fixed header/footer and a scrolling central area. Until now. Read more at [cubiq.org](http://cubiq.org).
Expand All @@ -19,6 +19,7 @@ iScroll is evolving thank to the help of all those who sent suggestions, bug rep

In completely random order:

- All Github [contributors](https://github.com/cubiq/iscroll/contributors)
- [beedesk](http://beedesk.com) for bug squashing in the pull to refresh feature
- [Daniel J. Pinter](http://twitter.com/#!/HeadDZombie) for continued support, bug reports and for killing zombies
- [Aseem Kishore](http://about.me/aseemk) for help with the zoom functionality
Expand Down
2 changes: 1 addition & 1 deletion examples/pull-to-refresh/index.html
Expand Up @@ -101,7 +101,7 @@

document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

document.addEventListener('DOMContentLoaded', setTimeout(function () { loaded(); }, 200), false);
document.addEventListener('DOMContentLoaded', function () { setTimeout(loaded, 200); }, false);
</script>

<style type="text/css" media="all">
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/index.html
Expand Up @@ -23,7 +23,7 @@
* Use this for high compatibility (iDevice + Android)
*
*/
document.addEventListener('DOMContentLoaded', setTimeout(function () { loaded(); }, 200), false);
document.addEventListener('DOMContentLoaded', function () { setTimeout(loaded, 200); }, false);
/*
* * * * * * * */

Expand Down
12 changes: 5 additions & 7 deletions src/iscroll-lite.js
Expand Up @@ -5,6 +5,7 @@

(function(){
var m = Math,
mround = function (r) { return r >> 0; },
vendor = (/webkit/i).test(navigator.appVersion) ? 'webkit' :
(/firefox/i).test(navigator.userAgent) ? 'Moz' :
'opera' in window ? 'O' : '',
Expand Down Expand Up @@ -143,8 +144,8 @@ iScroll.prototype = {
if (this.options.useTransform) {
this.scroller.style[vendor + 'Transform'] = trnOpen + x + 'px,' + y + 'px' + trnClose + ' scale(' + this.scale + ')';
} else {
x = m.round(x);
y = m.round(y);
x = mround(x);
y = mround(y);
this.scroller.style.left = x + 'px';
this.scroller.style.top = y + 'px';
}
Expand Down Expand Up @@ -193,9 +194,6 @@ iScroll.prototype = {
}
}

that.absStartX = that.x; // Needed by snap threshold
that.absStartY = that.y;

that.startX = that.x;
that.startY = that.y;
that.pointX = point.pageX;
Expand Down Expand Up @@ -322,7 +320,7 @@ iScroll.prototype = {
if (momentumX.dist || momentumY.dist) {
newDuration = m.max(m.max(momentumX.time, momentumY.time), 10);

that.scrollTo(m.round(newPosX), m.round(newPosY), newDuration);
that.scrollTo(mround(newPosX), mround(newPosY), newDuration);

if (that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
return;
Expand Down Expand Up @@ -456,7 +454,7 @@ iScroll.prototype = {
newDist = newDist * (dist < 0 ? -1 : 1);
newTime = speed / deceleration;

return { dist: newDist, time: m.round(newTime) };
return { dist: newDist, time: mround(newTime) };
},

_offset: function (el) {
Expand Down
25 changes: 12 additions & 13 deletions src/iscroll.js
Expand Up @@ -2,10 +2,9 @@
* iScroll v4.1.9 ~ Copyright (c) 2011 Matteo Spinelli, http://cubiq.org
* Released under MIT license, http://cubiq.org/license
*/

(function(){
var m = Math,
_round = function (r) { return r >> 0; },
mround = function (r) { return r >> 0; },
vendor = (/webkit/i).test(navigator.appVersion) ? 'webkit' :
(/firefox/i).test(navigator.userAgent) ? 'Moz' :
'opera' in window ? 'O' : '',
Expand Down Expand Up @@ -229,13 +228,13 @@ iScroll.prototype = {

if (dir == 'h') {
that.hScrollbarSize = that.hScrollbarWrapper.clientWidth;
that.hScrollbarIndicatorSize = m.max(_round(that.hScrollbarSize * that.hScrollbarSize / that.scrollerW), 8);
that.hScrollbarIndicatorSize = m.max(mround(that.hScrollbarSize * that.hScrollbarSize / that.scrollerW), 8);
that.hScrollbarIndicator.style.width = that.hScrollbarIndicatorSize + 'px';
that.hScrollbarMaxScroll = that.hScrollbarSize - that.hScrollbarIndicatorSize;
that.hScrollbarProp = that.hScrollbarMaxScroll / that.maxScrollX;
} else {
that.vScrollbarSize = that.vScrollbarWrapper.clientHeight;
that.vScrollbarIndicatorSize = m.max(_round(that.vScrollbarSize * that.vScrollbarSize / that.scrollerH), 8);
that.vScrollbarIndicatorSize = m.max(mround(that.vScrollbarSize * that.vScrollbarSize / that.scrollerH), 8);
that.vScrollbarIndicator.style.height = that.vScrollbarIndicatorSize + 'px';
that.vScrollbarMaxScroll = that.vScrollbarSize - that.vScrollbarIndicatorSize;
that.vScrollbarProp = that.vScrollbarMaxScroll / that.maxScrollY;
Expand All @@ -257,8 +256,8 @@ iScroll.prototype = {
if (this.options.useTransform) {
this.scroller.style[vendor + 'Transform'] = trnOpen + x + 'px,' + y + 'px' + trnClose + ' scale(' + this.scale + ')';
} else {
x = _round(x);
y = _round(y);
x = mround(x);
y = mround(y);
this.scroller.style.left = x + 'px';
this.scroller.style.top = y + 'px';
}
Expand All @@ -281,14 +280,14 @@ iScroll.prototype = {

if (pos < 0) {
if (!that.options.fixedScrollbar) {
size = that[dir + 'ScrollbarIndicatorSize'] + _round(pos * 3);
size = that[dir + 'ScrollbarIndicatorSize'] + mround(pos * 3);
if (size < 8) size = 8;
that[dir + 'ScrollbarIndicator'].style[dir == 'h' ? 'width' : 'height'] = size + 'px';
}
pos = 0;
} else if (pos > that[dir + 'ScrollbarMaxScroll']) {
if (!that.options.fixedScrollbar) {
size = that[dir + 'ScrollbarIndicatorSize'] - _round((pos - that[dir + 'ScrollbarMaxScroll']) * 3);
size = that[dir + 'ScrollbarIndicatorSize'] - mround((pos - that[dir + 'ScrollbarMaxScroll']) * 3);
if (size < 8) size = 8;
that[dir + 'ScrollbarIndicator'].style[dir == 'h' ? 'width' : 'height'] = size + 'px';
pos = that[dir + 'ScrollbarMaxScroll'] + (that[dir + 'ScrollbarIndicatorSize'] - size);
Expand Down Expand Up @@ -562,7 +561,7 @@ iScroll.prototype = {
}
}

that.scrollTo(_round(newPosX), _round(newPosY), newDuration);
that.scrollTo(mround(newPosX), mround(newPosY), newDuration);

if (that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
return;
Expand Down Expand Up @@ -770,7 +769,7 @@ iScroll.prototype = {
newDist = newDist * (dist < 0 ? -1 : 1);
newTime = speed / deceleration;

return { dist: newDist, time: _round(newTime) };
return { dist: newDist, time: mround(newTime) };
},

_offset: function (el) {
Expand Down Expand Up @@ -825,7 +824,7 @@ iScroll.prototype = {
that.currPageY = page;

// Snap with constant speed (proportional duration)
time = _round(m.max(sizeX, sizeY)) || 200;
time = mround(m.max(sizeX, sizeY)) || 200;

return { x: x, y: y, time: time };
},
Expand Down Expand Up @@ -887,8 +886,8 @@ iScroll.prototype = {
that.wrapperH = that.wrapper.clientHeight || 1;

that.minScrollY = -that.options.topOffset || 0;
that.scrollerW = _round(that.scroller.offsetWidth * that.scale);
that.scrollerH = _round((that.scroller.offsetHeight + that.minScrollY) * that.scale);
that.scrollerW = mround(that.scroller.offsetWidth * that.scale);
that.scrollerH = mround((that.scroller.offsetHeight + that.minScrollY) * that.scale);
that.maxScrollX = that.wrapperW - that.scrollerW;
that.maxScrollY = that.wrapperH - that.scrollerH + that.minScrollY;
that.dirX = 0;
Expand Down

0 comments on commit 8165866

Please sign in to comment.