Skip to content
This repository has been archived by the owner on Mar 27, 2019. It is now read-only.

Can now target different scroller #1022

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions build/iscroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,9 @@ var utils = (function () {

return me;
})();
function IScroll (el, options) {
function IScroll (el, options, scroller) {
this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
this.scroller = this.wrapper.children[0];
this.scrollerStyle = this.scroller.style; // cache style for better performance


this.options = {

Expand Down Expand Up @@ -303,8 +302,13 @@ function IScroll (el, options) {
HWCompositing: true,
useTransition: true,
useTransform: true,
bindToWrapper: typeof window.onmousedown === "undefined"
bindToWrapper: typeof window.onmousedown === "undefined",

snapWait: false
};

this.scroller = (typeof scroller == 'undefined') ? this.wrapper.children[0] : scroller;
this.scrollerStyle = this.scroller.style; // cache style for better performance

for ( var i in options ) {
this.options[i] = options[i];
Expand Down Expand Up @@ -1352,6 +1356,9 @@ IScroll.prototype = {
},

goToPage: function (x, y, time, easing) {
if(this.options.snapWait && ((!this.options.useTransition && this.isAnimating) || (this.options.useTransition && this.isInTransition)))
return;

easing = easing || this.options.bounceEasing;

if ( x >= this.pages.length ) {
Expand All @@ -1362,8 +1369,10 @@ IScroll.prototype = {

if ( y >= this.pages[x].length ) {
y = this.pages[x].length - 1;
return;
} else if ( y < 0 ) {
y = 0;
return;
}

var posX = this.pages[x][y].x,
Expand Down