Skip to content

Commit

Permalink
fix cubiq#414 cubiq#415 cubiq#416 and others, add startZoom option
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Spinelli committed Jul 9, 2013
1 parent 1aabafc commit dc40c9e
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 41 deletions.
4 changes: 2 additions & 2 deletions build/iscroll-lite.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.0.3 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.0.4 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
var IScroll = (function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down Expand Up @@ -296,7 +296,7 @@ function IScroll (el, options) {
}

IScroll.prototype = {
version: '5.0.3',
version: '5.0.4',

_init: function () {
this._initEvents();
Expand Down
25 changes: 18 additions & 7 deletions build/iscroll-probe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.0.3 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.0.4 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
var IScroll = (function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down Expand Up @@ -307,7 +307,7 @@ function IScroll (el, options) {
}

IScroll.prototype = {
version: '5.0.3',
version: '5.0.4',

_init: function () {
this._initEvents();
Expand Down Expand Up @@ -870,6 +870,7 @@ IScroll.prototype = {
_initIndicators: function () {
var interactive = this.options.interactiveScrollbars,
defaultScrollbars = typeof this.options.scrollbars != 'object',
customStyle = typeof this.options.scrollbars != 'string',
indicator1,
indicator2;

Expand All @@ -880,6 +881,7 @@ IScroll.prototype = {
el: createDefaultScrollbar('v', interactive, this.options.scrollbars),
interactive: interactive,
defaultScrollbars: true,
customStyle: customStyle,
resize: this.options.resizeIndicator,
listenX: false
};
Expand All @@ -893,6 +895,7 @@ IScroll.prototype = {
el: createDefaultScrollbar('h', interactive, this.options.scrollbars),
interactive: interactive,
defaultScrollbars: true,
customStyle: customStyle,
resize: this.options.resizeIndicator,
listenY: false
};
Expand Down Expand Up @@ -946,6 +949,10 @@ IScroll.prototype = {
},

_wheel: function (e) {
if ( !this.enabled ) {
return;
}

var wheelDeltaX, wheelDeltaY,
newX, newY,
that = this;
Expand Down Expand Up @@ -1050,7 +1057,7 @@ IScroll.prototype = {
n = -1;

for ( ; i < l; i++ ) {
if ( i === 0 || el[i].offsetLeft < el[i-1].offsetLeft ) {
if ( i === 0 || el[i].offsetLeft <= el[i-1].offsetLeft ) {
m = 0;
n++;
}
Expand Down Expand Up @@ -1217,7 +1224,7 @@ IScroll.prototype = {

x++;

if ( x >= this.pages.length && this.hasVericalScroll ) {
if ( x >= this.pages.length && this.hasVerticalScroll ) {
x = 0;
y++;
}
Expand All @@ -1231,7 +1238,7 @@ IScroll.prototype = {

x--;

if ( x < 0 && this.hasVericalScroll ) {
if ( x < 0 && this.hasVerticalScroll ) {
x = 0;
y--;
}
Expand Down Expand Up @@ -1276,6 +1283,10 @@ IScroll.prototype = {
},

_key: function (e) {
if ( !this.enabled ) {
return;
}

var snap = this.options.snap, // we are using this alot, better to cache it
newX = snap ? this.currentPage.pageX : this.x,
newY = snap ? this.currentPage.pageY : this.y,
Expand Down Expand Up @@ -1640,7 +1651,7 @@ Indicator.prototype = {
utils.addClass(this.wrapper, 'iScrollBothScrollbars');
utils.removeClass(this.wrapper, 'iScrollLoneScrollbar');

if ( this.options.defaultScrollbars ) {
if ( this.options.defaultScrollbars && this.options.customStyle ) {
if ( this.options.listenX ) {
this.wrapper.style.right = '8px';
} else {
Expand All @@ -1651,7 +1662,7 @@ Indicator.prototype = {
utils.removeClass(this.wrapper, 'iScrollBothScrollbars');
utils.addClass(this.wrapper, 'iScrollLoneScrollbar');

if ( this.options.defaultScrollbars ) {
if ( this.options.defaultScrollbars && this.options.customStyle ) {
if ( this.options.listenX ) {
this.wrapper.style.right = '2px';
} else {
Expand Down
29 changes: 20 additions & 9 deletions build/iscroll-zoom.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.0.3 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.0.4 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
var IScroll = (function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down Expand Up @@ -230,7 +230,7 @@ function IScroll (el, options) {
this.options = {

zoomMin: 1,
zoomMax: 4,
zoomMax: 4, startZoom: 1,

resizeIndicator: true,

Expand Down Expand Up @@ -297,7 +297,7 @@ function IScroll (el, options) {
this.directionY = 0;
this._events = {};

this.scale = 1;
this.scale = Math.min(Math.max(this.options.startZoom, this.options.zoomMin), this.options.zoomMax);

// INSERT POINT: DEFAULTS

Expand All @@ -309,7 +309,7 @@ function IScroll (el, options) {
}

IScroll.prototype = {
version: '5.0.3',
version: '5.0.4',

_init: function () {
this._initEvents();
Expand Down Expand Up @@ -864,6 +864,7 @@ IScroll.prototype = {
_initIndicators: function () {
var interactive = this.options.interactiveScrollbars,
defaultScrollbars = typeof this.options.scrollbars != 'object',
customStyle = typeof this.options.scrollbars != 'string',
indicator1,
indicator2;

Expand All @@ -874,6 +875,7 @@ IScroll.prototype = {
el: createDefaultScrollbar('v', interactive, this.options.scrollbars),
interactive: interactive,
defaultScrollbars: true,
customStyle: customStyle,
resize: this.options.resizeIndicator,
listenX: false
};
Expand All @@ -887,6 +889,7 @@ IScroll.prototype = {
el: createDefaultScrollbar('h', interactive, this.options.scrollbars),
interactive: interactive,
defaultScrollbars: true,
customStyle: customStyle,
resize: this.options.resizeIndicator,
listenY: false
};
Expand Down Expand Up @@ -1101,6 +1104,10 @@ IScroll.prototype = {
},

_wheel: function (e) {
if ( !this.enabled ) {
return;
}

var wheelDeltaX, wheelDeltaY,
newX, newY,
that = this;
Expand Down Expand Up @@ -1201,7 +1208,7 @@ IScroll.prototype = {
n = -1;

for ( ; i < l; i++ ) {
if ( i === 0 || el[i].offsetLeft < el[i-1].offsetLeft ) {
if ( i === 0 || el[i].offsetLeft <= el[i-1].offsetLeft ) {
m = 0;
n++;
}
Expand Down Expand Up @@ -1368,7 +1375,7 @@ IScroll.prototype = {

x++;

if ( x >= this.pages.length && this.hasVericalScroll ) {
if ( x >= this.pages.length && this.hasVerticalScroll ) {
x = 0;
y++;
}
Expand All @@ -1382,7 +1389,7 @@ IScroll.prototype = {

x--;

if ( x < 0 && this.hasVericalScroll ) {
if ( x < 0 && this.hasVerticalScroll ) {
x = 0;
y--;
}
Expand Down Expand Up @@ -1427,6 +1434,10 @@ IScroll.prototype = {
},

_key: function (e) {
if ( !this.enabled ) {
return;
}

var snap = this.options.snap, // we are using this alot, better to cache it
newX = snap ? this.currentPage.pageX : this.x,
newY = snap ? this.currentPage.pageY : this.y,
Expand Down Expand Up @@ -1803,7 +1814,7 @@ Indicator.prototype = {
utils.addClass(this.wrapper, 'iScrollBothScrollbars');
utils.removeClass(this.wrapper, 'iScrollLoneScrollbar');

if ( this.options.defaultScrollbars ) {
if ( this.options.defaultScrollbars && this.options.customStyle ) {
if ( this.options.listenX ) {
this.wrapper.style.right = '8px';
} else {
Expand All @@ -1814,7 +1825,7 @@ Indicator.prototype = {
utils.removeClass(this.wrapper, 'iScrollBothScrollbars');
utils.addClass(this.wrapper, 'iScrollLoneScrollbar');

if ( this.options.defaultScrollbars ) {
if ( this.options.defaultScrollbars && this.options.customStyle ) {
if ( this.options.listenX ) {
this.wrapper.style.right = '2px';
} else {
Expand Down
25 changes: 18 additions & 7 deletions build/iscroll.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.0.3 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.0.4 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
var IScroll = (function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down Expand Up @@ -304,7 +304,7 @@ function IScroll (el, options) {
}

IScroll.prototype = {
version: '5.0.3',
version: '5.0.4',

_init: function () {
this._initEvents();
Expand Down Expand Up @@ -861,6 +861,7 @@ IScroll.prototype = {
_initIndicators: function () {
var interactive = this.options.interactiveScrollbars,
defaultScrollbars = typeof this.options.scrollbars != 'object',
customStyle = typeof this.options.scrollbars != 'string',
indicator1,
indicator2;

Expand All @@ -871,6 +872,7 @@ IScroll.prototype = {
el: createDefaultScrollbar('v', interactive, this.options.scrollbars),
interactive: interactive,
defaultScrollbars: true,
customStyle: customStyle,
resize: this.options.resizeIndicator,
listenX: false
};
Expand All @@ -884,6 +886,7 @@ IScroll.prototype = {
el: createDefaultScrollbar('h', interactive, this.options.scrollbars),
interactive: interactive,
defaultScrollbars: true,
customStyle: customStyle,
resize: this.options.resizeIndicator,
listenY: false
};
Expand Down Expand Up @@ -937,6 +940,10 @@ IScroll.prototype = {
},

_wheel: function (e) {
if ( !this.enabled ) {
return;
}

var wheelDeltaX, wheelDeltaY,
newX, newY,
that = this;
Expand Down Expand Up @@ -1037,7 +1044,7 @@ IScroll.prototype = {
n = -1;

for ( ; i < l; i++ ) {
if ( i === 0 || el[i].offsetLeft < el[i-1].offsetLeft ) {
if ( i === 0 || el[i].offsetLeft <= el[i-1].offsetLeft ) {
m = 0;
n++;
}
Expand Down Expand Up @@ -1204,7 +1211,7 @@ IScroll.prototype = {

x++;

if ( x >= this.pages.length && this.hasVericalScroll ) {
if ( x >= this.pages.length && this.hasVerticalScroll ) {
x = 0;
y++;
}
Expand All @@ -1218,7 +1225,7 @@ IScroll.prototype = {

x--;

if ( x < 0 && this.hasVericalScroll ) {
if ( x < 0 && this.hasVerticalScroll ) {
x = 0;
y--;
}
Expand Down Expand Up @@ -1263,6 +1270,10 @@ IScroll.prototype = {
},

_key: function (e) {
if ( !this.enabled ) {
return;
}

var snap = this.options.snap, // we are using this alot, better to cache it
newX = snap ? this.currentPage.pageX : this.x,
newY = snap ? this.currentPage.pageY : this.y,
Expand Down Expand Up @@ -1622,7 +1633,7 @@ Indicator.prototype = {
utils.addClass(this.wrapper, 'iScrollBothScrollbars');
utils.removeClass(this.wrapper, 'iScrollLoneScrollbar');

if ( this.options.defaultScrollbars ) {
if ( this.options.defaultScrollbars && this.options.customStyle ) {
if ( this.options.listenX ) {
this.wrapper.style.right = '8px';
} else {
Expand All @@ -1633,7 +1644,7 @@ Indicator.prototype = {
utils.removeClass(this.wrapper, 'iScrollBothScrollbars');
utils.addClass(this.wrapper, 'iScrollLoneScrollbar');

if ( this.options.defaultScrollbars ) {
if ( this.options.defaultScrollbars && this.options.customStyle ) {
if ( this.options.listenX ) {
this.wrapper.style.right = '2px';
} else {
Expand Down
Loading

0 comments on commit dc40c9e

Please sign in to comment.