Skip to content

Commit

Permalink
mandatory bug fixes after a main release. see release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
cubiq committed Jan 9, 2014
1 parent 03a3c14 commit 44d992b
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 60 deletions.
3 changes: 2 additions & 1 deletion .nodemonignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/build/*
/dist/*
/demos/*
*.md
*.md
*.tmp
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# iScroll, smooth scrolling for the web
<h1 id="intro">iScroll, smooth scrolling for the web</h1>

iScroll is a high performance, small footprint, dependency free, multi-platform javascript scroller.

Expand Down Expand Up @@ -71,7 +71,9 @@ So basically either you pass the element directly or a string that will be given
Note that iScroll uses `querySelector` not `querySelectorAll`, so only the first occurrence of the selector is used. If you need to apply iScroll to multiple objects you'll have to build your own cycle.

<div class="tip">
<p>You don't strictly need to assign the instance to a variable (<code>myScroll</code>), but it is handy to keep a reference to the iScroll (for example you could later check the scroller position).</p>
<p>You don't strictly need to assign the instance to a variable (<code>myScroll</code>), but it is handy to keep a reference to the iScroll.</p>

For example you could later check the <a href="#scroller-info">scroller position</a> or <a href="#destroy">unload unnecessary events</a> when you don't need the iScroll anymore.</p>
</div>

<h2 id="initialization">Initialization</h2>
Expand Down Expand Up @@ -415,7 +417,7 @@ These are the same options we explored in the [scrollbars section](#scrollbars),

Have a look at the [minimap demo](http://lab.cubiq.org/iscroll5/demos/minimap/) to get a glance at the power of the `indicators` option.

The wittiest of you would have noticed that `indicators` is actually plural... Yes, exactly, passing an array of objects you can have a virtually infinite number of indicators. I don't what you may need them for, but hey! who am I to argue about your scrollbar preferences?
The wittiest of you would have noticed that `indicators` is actually plural... Yes, exactly, passing an array of objects you can have a virtually infinite number of indicators. I don't know what you may need them for, but hey! who am I to argue about your scrollbar preferences?

## <span id="parallax-scrolling">Parallax scrolling</span>

Expand Down Expand Up @@ -610,6 +612,12 @@ Duration in millisecond of the bounce animation.

Default: `600`

### <small>options.</small>deceleration

This value can be altered to change the momentum animation duration/speed. Higher numbers make the animation shorter. Sensible results can be experienced starting with a value of `0.01`, bigger than that basically doesn't make any momentum at all.

Default: `0.0006`

### <small>options.</small>mouseWheelSpeed

Set the speed of the mouse wheel.
Expand Down Expand Up @@ -766,7 +774,7 @@ It's impossible to track all the websites and applications that use the iScroll.
<h2 id="license">License (MIT)</h2>


Copyright (c) 2014 Matteo Spinelli, http://cubiq.org/
Copyright (c) 2014 Matteo Spinelli, [cubiq.org](http://cubiq.org/)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
34 changes: 34 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Release notes for iScroll

---

## Version 5.1.1 - 2014.01.10

### Fixes
* Infinite scroll now switch from `transform` to `top/left` based on `useTransform` option.
* [#555](https://github.com/cubiq/iscroll/issues/555) removed unused variable
* [#372](https://github.com/cubiq/iscroll/issues/372) case insensitive check on tag names

### New features
* New `off` method to unload custom events
* Added `options.deceleration` to alter the momentum duration/speed
* Added release notes file

---

## Version 5.1.0 - 2014.01.09

### Fixes
* [#558](https://github.com/cubiq/iscroll/issues/558) false positive for `isBadAndroid`

### New features
* Infinite scrolling
* Documentation
* `_execEvent` supports arguments

### Changes
* dist/minified files are no longer pushed to the main repo

---

*I started collecting release notes from version 5.1.0*
39 changes: 30 additions & 9 deletions build/iscroll-infinite.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
(function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down Expand Up @@ -47,12 +47,13 @@ var utils = (function () {
el.removeEventListener(type, fn, !!capture);
};

me.momentum = function (current, start, time, lowerMargin, wrapperSize) {
me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
var distance = current - start,
speed = Math.abs(distance) / time,
destination,
duration,
deceleration = 0.0006;
duration;

deceleration = deceleration === undefined ? 0.0006 : deceleration;

destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
duration = speed / deceleration;
Expand Down Expand Up @@ -219,7 +220,7 @@ var utils = (function () {
var target = e.target,
ev;

if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') {
if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
ev = document.createEvent('MouseEvents');
ev.initMouseEvent('click', true, true, e.view, 1,
target.screenX, target.screenY, target.clientX, target.clientY,
Expand All @@ -245,6 +246,9 @@ function IScroll (el, options) {

snapThreshold: 0.334,

infiniteUseTransform: true,
deceleration: 0.004,

// INSERT POINT: OPTIONS

startX: 0,
Expand Down Expand Up @@ -299,6 +303,7 @@ function IScroll (el, options) {
if ( this.options.infiniteElements ) {
this.options.probeType = 3;
}
this.options.infiniteUseTransform = this.options.infiniteUseTransform && this.options.useTransform;

if ( this.options.probeType == 3 ) {
this.options.useTransition = false; }
Expand All @@ -322,7 +327,7 @@ function IScroll (el, options) {
}

IScroll.prototype = {
version: '5.1.0',
version: '5.1.1',

_init: function () {
this._initEvents();
Expand Down Expand Up @@ -571,8 +576,8 @@ IScroll.prototype = {

// start momentum animation if needed
if ( this.options.momentum && duration < 300 ) {
momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0) : { destination: newX, duration: 0 };
momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0) : { destination: newY, duration: 0 };
momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 };
momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 };
newX = momentumX.destination;
newY = momentumY.destination;
time = Math.max(momentumX.duration, momentumY.duration);
Expand Down Expand Up @@ -711,6 +716,18 @@ IScroll.prototype = {
this._events[type].push(fn);
},

off: function (type, fn) {
if ( !this._events[type] ) {
return;
}

var index = this._events[type].indexOf(fn);

if ( index > -1 ) {
this._events[type].splice(index, 1);
}
},

_execEvent: function (type) {
if ( !this._events[type] ) {
return;
Expand Down Expand Up @@ -1443,7 +1460,11 @@ IScroll.prototype = {

if ( this.infiniteElements[i]._phase < this.options.infiniteLimit ) {
this.infiniteElements[i]._top = top;
this.infiniteElements[i].style.top = top + 'px';
if ( this.options.infiniteUseTransform ) {
this.infiniteElements[i].style[utils.style.transform] = 'translate(0, ' + top + 'px)' + this.translateZ;
} else {
this.infiniteElements[i].style.top = top + 'px';
}
update.push(this.infiniteElements[i]);
}
}
Expand Down
29 changes: 21 additions & 8 deletions build/iscroll-lite.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
(function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down Expand Up @@ -47,12 +47,13 @@ var utils = (function () {
el.removeEventListener(type, fn, !!capture);
};

me.momentum = function (current, start, time, lowerMargin, wrapperSize) {
me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
var distance = current - start,
speed = Math.abs(distance) / time,
destination,
duration,
deceleration = 0.0006;
duration;

deceleration = deceleration === undefined ? 0.0006 : deceleration;

destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
duration = speed / deceleration;
Expand Down Expand Up @@ -219,7 +220,7 @@ var utils = (function () {
var target = e.target,
ev;

if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') {
if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
ev = document.createEvent('MouseEvents');
ev.initMouseEvent('click', true, true, e.view, 1,
target.screenX, target.screenY, target.clientX, target.clientY,
Expand Down Expand Up @@ -309,7 +310,7 @@ function IScroll (el, options) {
}

IScroll.prototype = {
version: '5.1.0',
version: '5.1.1',

_init: function () {
this._initEvents();
Expand Down Expand Up @@ -536,8 +537,8 @@ IScroll.prototype = {

// start momentum animation if needed
if ( this.options.momentum && duration < 300 ) {
momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0) : { destination: newX, duration: 0 };
momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0) : { destination: newY, duration: 0 };
momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 };
momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 };
newX = momentumX.destination;
newY = momentumY.destination;
time = Math.max(momentumX.duration, momentumY.duration);
Expand Down Expand Up @@ -655,6 +656,18 @@ IScroll.prototype = {
this._events[type].push(fn);
},

off: function (type, fn) {
if ( !this._events[type] ) {
return;
}

var index = this._events[type].indexOf(fn);

if ( index > -1 ) {
this._events[type].splice(index, 1);
}
},

_execEvent: function (type) {
if ( !this._events[type] ) {
return;
Expand Down
30 changes: 21 additions & 9 deletions build/iscroll-probe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
(function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down Expand Up @@ -47,12 +47,13 @@ var utils = (function () {
el.removeEventListener(type, fn, !!capture);
};

me.momentum = function (current, start, time, lowerMargin, wrapperSize) {
me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
var distance = current - start,
speed = Math.abs(distance) / time,
destination,
duration,
deceleration = 0.0006;
duration;

deceleration = deceleration === undefined ? 0.0006 : deceleration;

destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
duration = speed / deceleration;
Expand Down Expand Up @@ -219,7 +220,7 @@ var utils = (function () {
var target = e.target,
ev;

if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') {
if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
ev = document.createEvent('MouseEvents');
ev.initMouseEvent('click', true, true, e.view, 1,
target.screenX, target.screenY, target.clientX, target.clientY,
Expand Down Expand Up @@ -324,7 +325,7 @@ function IScroll (el, options) {
}

IScroll.prototype = {
version: '5.1.0',
version: '5.1.1',

_init: function () {
this._initEvents();
Expand Down Expand Up @@ -573,8 +574,8 @@ IScroll.prototype = {

// start momentum animation if needed
if ( this.options.momentum && duration < 300 ) {
momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0) : { destination: newX, duration: 0 };
momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0) : { destination: newY, duration: 0 };
momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 };
momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 };
newX = momentumX.destination;
newY = momentumY.destination;
time = Math.max(momentumX.duration, momentumY.duration);
Expand Down Expand Up @@ -709,6 +710,18 @@ IScroll.prototype = {
this._events[type].push(fn);
},

off: function (type, fn) {
if ( !this._events[type] ) {
return;
}

var index = this._events[type].indexOf(fn);

if ( index > -1 ) {
this._events[type].splice(index, 1);
}
},

_execEvent: function (type) {
if ( !this._events[type] ) {
return;
Expand Down Expand Up @@ -902,7 +915,6 @@ IScroll.prototype = {

_initIndicators: function () {
var interactive = this.options.interactiveScrollbars,
defaultScrollbars = typeof this.options.scrollbars != 'object',
customStyle = typeof this.options.scrollbars != 'string',
indicators = [],
indicator;
Expand Down
Loading

0 comments on commit 44d992b

Please sign in to comment.