> iScroll

iScroll v3

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.

This script has been superseded by iScroll 4. This page is kept for historical reasons.


Project info

Project state: ACTIVE (code is actively updated)
Last code update: 2010.10.08 – v3.7.1
Device compatibility: iPhone/Ipod touch >=2.0, Android >=1.5, iPad >=3.2.
Discussion Group
QR Code opens demo page.

Support development

If this script saved your day or you wish to support iScroll and other scripts development you may consider sending some funds via PayPal.





Overview

iScroll was born because mobile webkit (on iPhone, iPod, Android and Pre) does not provide a native way to scroll content inside a fixed width/height element. This unfortunate situation prevents any web-app to have a position:absolute header and/or footer and a scrolling central area for contents.

Luckily mobile webkit offers a powerful set of hardware accelerated CSS properties that can be used to simulate the missing functionality, so the iScroll development started… But there’s no rose without thorn. Making the scroll feel native has proven more difficult than expected.

How to use

First of all we need to prevent the default behavior of standard touch events. This is easily done adding preventDefault() to the touchmove event. Then initialize the iScroll object on DOMContentLoaded or on window load. Here an example:

function loaded() {
	document.addEventListener('touchmove', function(e){ e.preventDefault(); });
	myScroll = new iScroll('scroller');
}
document.addEventListener('DOMContentLoaded', loaded);

iScroll takes two parameters. The first is mandatory and is the ID of the element you want to scroll. The second is optional and can be used to pass additional parameters (see below).

On the HTML/CSS side the scrolling area needs to be wrapped by an element which determines the scroller actual size. The following is a common tags configuration for an iScroll.

<div id="wrapper">
    <div id="scroller">
        <ul>
            <li>...</li>
        </ul> 
    </div> 
</div>

The #wrapper also needs some classes:

#wrapper {
    position:relative;
    z-index:1;
    width:/* your desired width, auto and 100% are fine */;
    height:/* element height */;
    overflow:/* hidden|auto|scroll */;
}

That’s it. Enjoy your scrolling. Have a look at the source code of the online example to get a better idea of how the iScroll works.

Syntax

The iScroll syntax is: iScroll(mixed element_id, object options).

element_id, can be both an object pointing to or a string with the ID name of the element to be scrolled. Example: iScroll(document.getElementsByTagName('div')[1]) or iScroll('scroller')

Accepted options are:

  • hScrollbar: set to false to never show the horizontal scrollbar. The default value true makes the iScroll smartly decide when the scrollbar is needed. Note that if device does not support translate3d hScrollbar is set to false by default.
  • vScrollbar: set to false to never show the vertical bar. The default value true makes the iScroll smartly decide when the scrollbar is needed. Note that if device does not support translate3d vScrollbar is set to false by default.
  • bounce: set to false to prevent the scroller to bounce outside of boundaries (Android behavior). Default true (iPhone behavior).
  • bounceLock:, if set to true the scroller stops bouncing if the content is smaller than the visible area. Default: false (as per native iphone scroll).
  • checkDOMChanges: set to false to prevent auto refresh on DOM changes. If you switch off this feature you have to call iScroll.refresh() function programmatically every time the DOM gets modified. If your code makes many subsequent DOM modifications it is suggested to set checkDOMChanges to false and to refresh the iScroll only once (ie: when all changes have been done). Default true.
  • fadeScrollbar: define wether the scrollbars should fade in/out. Default true on iPhone, false on Android. Set to false for better performance.
  • momentum: set to false to remove the deceleration effect on swipe. Default true on devices that support translate3d.
  • shrinkScrollbar: set to false to remove the shrinking scrollbars when content is dragged over the boundaries. Default true on iPhone, false on Android. It has no impact on performances.
  • desktopCompatibility: for debug purpose you can set this to true to have the script behave on desktop webkit (Safari and Chrome) as it were a touch enabled device.
  • snap: set to true to activate snap scroll.
  • scrollbarColor: changes the color of the scrollbar. It accepts any valid CSS color (default: 'rgba(0,0,0,0.5)'

Note: options must be sent as object not string. Eg:

myScroll = new iScroll(’scroller’, { checkDOMChanges: false, bounce: false, momentum: false });

Snap scroll

When calling iScroll with “snap” option the scrolling area is subdivided into pages and whenever you swipe the scroll position will always snap to the page. Have a look at the screencast to get an idea.

Probably the best way to use “snap” is by calling it without momentum and scrollbars:

new iScroll('scroller', { snap:true, momentum:false, hScrollbar:false, vScrollbar:false });

If you keep momentum, you get a free-scrolling that will always stop to prefixed positions.

To have a perfect snapping experience the scrolling area should be perfectly divisible by the container size. Eg: If the container width is 200px and you have 10 elements, the whole scroller should be 2000px wide. This is not mandatory as iScroll doesn’t break if the last page is smaller than the container.

Methods

  • refresh(): updates all iScroll variables. Useful when the content of the page doesn’t scroll and just “jumps back”. Call refresh() inside a zero setTimeout. Eg: setTimeout(function () { myScroll.refresh() }, 0).
  • scrollTo(x, y, timeout): scrolls to any x,y location inside the scrolling area.
  • scrollToElement(el, runtime): scrolls to any element inside the scrolling area. el must be a CSS3 selector. Eg: scrollToElement("#elementID", '400ms').
  • scrollToPage(pageX, pageY, runtime): if snap option is active, scrolls to any page. pageX and pageY can be an integer or prev/next. Two keywords that snap to previous or next page in the raw. The “carousel” example in the zip file is a good starting point on using the snap feature.
  • destroy(full): completely unloads the iScroll. If called with full set to true, the scroller is also removed from the DOM.

Best practices

DOM Changes – If scrolling doesn’t work after an ajax call and DOM change, try to initialize iScroll with checkDOMChanges: false and call refresh() function once the DOM modifications have been done. If this still doesn’t work try to put refresh() inside a 0ms setTimeout. Eg:

setTimeout(function () { myScroll.refresh(); }, 0);

Performance – CSS animations are heavy on the small device CPU. When too many elements are loaded into the scrolling area expect choppy animation. Try to reduce the number of tags inside the scrolling area to the minimum. Try to use just ULs for lists and Ps for paragraphs. Remember that you don’t actually need an anchor to create a button or send an action, so <li><a href="#" onclick="..." />text</a></li> is a waste of tags. You could remove the anchor and place the click event directly on the LI tag.

Try to avoid box-shadow and CSS gradients (especially on Android). I know they are cool and classy, but they don’t play well with CSS animations. Webkit on iPhone seems to handle shadows and gradients a bit better than its counterpart on Android, so you may selectively add/remove features based on the device.

Use a flat color for the #wrapper background, images in the scroller wrapper once again reduce performance.

Important: to preserve resources on devices that don’t support translate3d (namely: Android<2.0) iScroll disables momentum, scrollbars and bounce. You can however reactivate them using the respective options.

Bugs and limitations

Form fields do not play well with CSS animations. Countermeasures have to be adopted on a case-by-case basis.

Please use the issue tracker on Google Code to submit a bug report. You can also follow day by day updates on Google Code.

Future developments

  • I’m considering Palm Pre compatibility.
  • Check for multiple consecutive changes to the DOM to prevent unnecessary calls to the refresh() function.
  • Maybe we can achive better performances with lazy loading and pre-fetching. Lazy loading takes care of loading and unloading elements when they are not needed (ie: out of the screen). Pre-fetching can be used to preload all elements to reduce flickering.

FAQ

Q: Why on Android 1.5/1.6 I’m not seeing the scrollbars?
A: On older devices iScroll disables the scrollbars and other effects. You can reactivate them passing the hScrollbar:true and/or vScrollbar:true options.

Q: Why aren’t you adding feature X?
A: I’d like to keep the iScroll as bare-bone as possible, before adding a new feature I carefully estimate the pros and the cons.

Q: I’ve developed feature X, may I send it to you?
A: Please do! It’s not guaranteed that I will add your feature to the script, but I review all code you send to me.

Q: I’m in a hurry and I need feature X to be added to your script ASAP. Can you help me?
A: Have you considered hiring me?

Revisions history

v3.7.1, 2010.10.08 – Bug fix
v3.7, 2010.10.05 – Lock scrolling direction, added bounceLock and scrollbarColor options, size optimization.
v3.6, 2010.08.24 – Bug Squashing Edition.
v3.6 beta 1, 2010.08.10 – Added snap scroll.
v3.5.1, 2010.07.30 – Mandatory bug fix.
v3.5, 2010.07.27 – Added scrollToElement() method, fixed a bug with scrollbars and multiple iScroll instances, a bit of code clean up.
v3.4.5, 2010.07.04 – Prevent JS error on browsers not supporting WebKitCSSMatrix.
v3.4.4, 2010.06.30 – Better orientation detection.
v3.4.3, 2010.06.27 – Bug fix.
v3.4.2, 2010.06.24 – Bug fix.
v3.4.1, 2010.06.24 – Enhanced shrinking scrollbars.
v3.4, 2010.06.20 – Shrinking scrollbars and preliminary desktop compatibility.
v3.3, 2010.06.11 – Code freeze, let’s go for 3.4.
v3.3 beta 3, 2010.06.10 – Full (?!) Android compatibility.
v3.3 beta 2, 2010.06.08 – Better Android compatibility.
v3.3 beta 1, 2010.06.04 – Added Android >=1.5 compatibility.
v3.2.1, 2010.06.03 – Bug fix.
v3.2, 2010.05.31 – Code clean up.
v3.1 beta 1, 2010.05.06 – Added auto refresh on DOM changes.
v3.0 alpha 1, 2009.11.30 – Complete code rewrite. Scrollbars added. Optimized deceleration.
v2.3, 2009.07.09 – translate() replaced by translate3d().
v2.2, 2009.06.18 – Added OS3.0 compatibility.
v2.1, 2009.02.12 – Added refresh() function.
v2.0, 2009.02.03 – Optimized deceleration formula.
v1.1, 2009.01.18 – Removed timers.
v1.0, 2009.01.03 – Initial release.

/Share the joy

/Reactions

  • Amazing script! Works great on a web app I am working on.

    Is there a way this can be applied so the wrapper and the scrollable div are identified by class instead of id? I have 5 scrollers going on right now and it would reduce redundancy…

    Thanks! Very nicely done.

    • Something like this should do the trick (didn’t test sorry, but should work):

      var i, elems, scrollers = [];
      elems = document.querySelectorAll(".theClassName");
      
      for (i=0; i<elems.length; i++) {
        scrollers[i] = new iScroll(elems[i]);
      }
    • Author: Paul Herz
    • Posted on: 2010/05/22
    • At: 02:07

    It keeps going past the end and glitching up when I go from portrait -> landscape. What am I doing wrong?

    • Author: rodivi
    • Posted on: 2010/05/24
    • At: 18:03

    Hi Matteo,

    Great job!

    I’m afraid it is mandatory the element to scroll (not the wrapper) to have a fixed width / height. Isn’t it?

    I’m trying to do the trick with a text page (variable text length) and it doesnt works at espected at the end of the text.

    • No, the scroller can be of any size. You probably have a html/css issue. Hard to say without looking at the code.

      • Author: rodivi
      • Posted on: 2010/05/25
      • At: 23:15

      You were right, it was a shrink wrap issue :) Thanks for your time and dedication!

    • Author: Alex C
    • Posted on: 2010/05/24
    • At: 19:39

    This script is the bomb! Thanks. I’ve been trying to implement (window.scrollTo(0, 1);) to hide the URL bar but I can’t get it to work. Is there an easy fix for doing this? Thanks.

    • Author: Loan Myers
    • Posted on: 2010/05/25
    • At: 17:06

    Thank you so much for the Library. Its working great

    • Author: Loan Myers
    • Posted on: 2010/05/26
    • At: 02:48

    I tried implementing the scroller as a class but some reason it’s not working. The first page works fine but not the other ones.

    Has anyone had issues with this? Or is there something I’m missing in my code.

    Thanks!

    Here’s my code:

    function loaded()
    {
    document.addEventListener(‘touchmove’, function(e){ e.preventDefault(); });

    var i;
    var scrollers = [];
    var elems = document.querySelectorAll(“div.scroller”);
    for (i = 0; i < elems.length; i++)
    {
    scrollers[i] = new iScroll(elems[i]);
    }
    }
    document.addEventListener('DOMContentLoaded', loaded);

    CSS:

    .scroller
    {
    background: url(../images/bg.jpg) no-repeat #000;
    float:left;
    width:100%;
    padding:0;
    }

    .wrapper
    {
    position: relative;
    z-index: 1;
    width: 320px;
    height: 390px;
    overflow: hidden;
    }

    • Author: Yoav
    • Posted on: 2010/05/26
    • At: 16:52

    you’ve done a great job here. It would be great if this was a Jquery plugin that could simply be called like $(‘#div’).iscroll(). A similar plugin exists (jScrollTouch) but does not handle the smooth scrolling like you’ve accomplished

      • Author: Damien
      • Posted on: 2010/06/02
      • At: 20:27

      I am the developer of jScrollTouch, what do you mean by smooth scrolling?

      I just released jSlideTouch to slide photos or any content.

    • Author: Nathaniel
    • Posted on: 2010/05/27
    • At: 18:22

    Has anyone had any luck using iScroll with jqTouch? I’m having problems because all the divs I want to scroll are hidden on load except one. O have tried only calling new iscroll when that div is shown, but I’m going to have 10 plus scrollable divs. It seems to work, but then my transitions between divs get messed up. Any thoughts would be appreciated.

      • Author: Sebas
      • Posted on: 2010/05/30
      • At: 05:21

      Hi Nathaniel,

      I dont know about jqTouch, but I got a similar transition problem with prototype and scriptaculous.

      What i found is that when the element (or a parent element) is hidden with a display ‘none’ at start, the iScroll script has problem initiating the scroll properly – probably more Safari on iPad and the webkit 3d rendering, than the script itself.

      I used display ‘hidden’ instead, and it worked. I still had to wait that my transitions ends-up before instanciating the iScroll object, because this was shredding them to pieces – 3d rendering doesnt seem to play well with thoses. But its so fast..

      Hope this will help you a bit.

      This script is so cool, nicely coded, and saved me many hours.
      Thank you Matteo !

    • Author: Janae
    • Posted on: 2010/05/28
    • At: 18:59

    Awesome script! It has been invaluable with my iphone web app!

    • Author: Sebas
    • Posted on: 2010/05/30
    • At: 05:40

    Hi Matteo,

    I would like to know if there is an easy way to prevent the scroller to go outside boundaries.

    I tried to change the constants in ‘onTouchMove’ – put 40 in place of 4, for example – and ‘momentum’, but the result was not very nice, and was not constant depending of the gestures/method. I understand that this is maybe not possible without breaking the nice transitions. Any suggestion is welcome.

    I saw you have a bounce option, and I tried to set it to false before realising it is not used in the library. Is it deprecated or a provision ?

    Again, thank you very much !

    • To prevent the bounce effect we have to modify the touchmove and the momentum functions. It’s a quick fix and will be regulated by the “bounce” argument (just a reminder at the moment).

      I will add this functionality in the next version (couple of days).

    • Author: mila
    • Posted on: 2010/05/31
    • At: 09:48

    Hi Matt,

    great scripts, saved me tones of time and arguments with my boss. But i can’t get the horizontal scrolling to work properly. Do you have any suggestions?

    i set the width and height of the wrapper dynamically :

    wrapper.style.height = screenHeight-220+'px';
    wrapper.style.width = screenWidth-20+'px';

    is that the problem?

    thanks.

      • Author: mila
      • Posted on: 2010/05/31
      • At: 10:16

      got it, forgot the z-index value and the position absolute and top was nessesary.

      but now i’ve got another problem the content is not really sharp anymore… what could cause that kind of problem??

    • mmmh… do you have <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />?

    • Author: Marc
    • Posted on: 2010/06/01
    • At: 16:40

    Hi Matt,

    i think the line

    this.wrapper.style.overflow = ‘hidden’;

    is still required.
    in my application, the absence of that line in IScroll v3.2 causes the scroller to be bleed through an element which occurs just before the iscroll wrapper element.

    • it is left to the user to add the overflow property in the stylesheet. Someone may need overflow:scroll or auto for desktop browser compatibility. Actually I could add:
      this.wrapper.style.overflow = ‘auto’; which would make it compatible with everything.

    • Author: Loan Myers
    • Posted on: 2010/06/03
    • At: 04:20

    Hi Matteo,

    I was just wondering does the the div ‘scroller’ and the div ‘wrapper’ have to be named those exact names?

    When I change the names, it stops working. Also, is their a limit to the amount you can use on ones page? I’ve tried to implement multiple iScrolls using the array method you suggest in the first post but it stops applying the scroller after the first div.

    • You can name them whatever you want. And virtually there’s no limit to the number of scrollers in a page… I’d say the limit is the device memory.

    • Author: YouMeng
    • Posted on: 2010/06/03
    • At: 12:30

    Hi, is it possible to use this on Android 1.5?

    • Come back in a couple of hours, I’m updating the script with Android compatibility down to 1.5

    • Author: Celtiore
    • Posted on: 2010/06/03
    • At: 12:51

    Thanks you veru much :p

    • Author: YouMeng
    • Posted on: 2010/06/03
    • At: 13:07

    Thank you so much :)

    • whoops, sorry. I’ll probably publish the updated version tomorrow (GMT+2). I added Android >=1.5 compatibility and a couple of new features but I need some more time for beta testing.

    • Author: HANZUBON
    • Posted on: 2010/06/03
    • At: 18:43

    On iPhone, Long touch on < a > tag link will show browser pop-up for open new window, url copy and so on.

    But on < a > link inside the iscroll area, this function does not work.

    Because preventDefault() in onTouchStart event handler will kill touchstart event for iPhone browser default event handler(touchstart event will not rise on browser default event handler, so Long touch can not detect on the browser)

    I think this preventDefault() is to stop the browser native scroll, isn’t it?

    If so, I think preventDefault() can move to onTouchMove event handler and solve this pop-up does not work problem.

    • Yes, preventDefault() prevents the popup to come out. There’s little we can do about it. Killed popup is a little price to pay compared to the benefits of having the scroll back.

      Maybe you can try placing the preventdefault in the touchmove event instead of the touchstart.

    • Author: Mark
    • Posted on: 2010/06/03
    • At: 21:19

    Fabulous script!

    Doesn’t addEventListener require three parameters, though? I was getting inconsistent behavior until I added a third “false” parameter to all the addEventListener calls. Then it worked great.

  • has anyone successfully implemented a fully horizontal example of this script?

    i am having some trouble getting it to work well and resize content when the device orientation changes… any tips?

      • Author: michael
      • Posted on: 2010/06/09
      • At: 23:38

      Do you have a link to where we can see the problem?

      • Author: Thomas
      • Posted on: 2010/09/09
      • At: 16:58

      I’m having the same issue on a fully horizontal layout.

      Works great on a vertical device. Very clumsy when orientation changes to horizontal.

      Here is the link :
      http://www.florencemoll.com/billy-and-hells

    • Author: Michael
    • Posted on: 2010/06/04
    • At: 17:53

    Great script and it works great!

    How would I implement an iframe where the list shows. I tried adding an iframe to load a separate html page, but the page gets cut off and the scrolling won’t work. Is this even possible?

    Thanks again

    • Author: Jim
    • Posted on: 2010/06/04
    • At: 20:18

    This is an awesome script, really appreciate the effort. I was hoping someone could lead me in the right path to get my select boxes working, and info would be appreciated.

    Thanks

      • Author: Jim
      • Posted on: 2010/06/04
      • At: 21:17

      I am replying the solution to myself, it seems some post above talk about moving the “preventDefault” function to the ontouchmove event instead of ontouchstart, this seems to do the trick for me. Hope this helps someone else.

  • Very cool.
    iscroll.js is what i found when i went to nike.com with my ipad.

    Congrats out to Matteo for getting something nice enough such that the guys at Nike use this.

    tight clean code – 2 thumbs up.

    • Author: Hubert Halkin
    • Posted on: 2010/06/05
    • At: 18:36

    Great job! Thank you.

    If “myScroll = new iScroll(‘id’);” is triggered by document.DOMContentLoaded then the calculation (by isScroll.js) of the dimensions of the scrolling element does not include the contribution of images contained in the scrolling element. If “myScroll = new iScroll(‘id’);” is triggered by “<body onload=…" then there is no problem.

    • This shouldn’t be a problem as images should all have width and height properties. But, yes, window.load can be used as well. Probably an additional 100ms should be added if you use onload.

  • Thank you so much for your plugin. I’ve been fighting for a week now trying to make this work.

    I do wish there were clearer examples for some of the interesting tidbits people leave lying around, though. Yours was the clearest (I couldn’t make head or tails of TouchScroll because of his example)

    • Author: Fabio Morreale
    • Posted on: 2010/06/07
    • At: 14:08

    Grazie Matteo,
    script utilissimo!

    • Author: Rory
    • Posted on: 2010/06/07
    • At: 14:22

    Great script, most of this was very clear and much better than other examples on the web, but please could somebody give some details on how to configure the ‘options’ to this. I am having trouble getting this to work for horizontal scroll.

    • Make the scroller width:1000px (for example) instead of 100%, iscroll should automatically configure itself for horizontal scrolling.

  • Hi Matteo,

    You mention that Andorid browsers need a refresh after following the QR code…

    I have been launching the demo via the “Live Demo” link and from a homepage bookmark. Both of these methods require me to refresh the page in order to get correct positioning of the footer. Were you aware of this?

    My tests have been on a Nexus One with Froyo.

    Thanks again for your work on this great project :)

    • thanks for your report. Yes, I’m aware of it. I’m working on a more stable demo for Android users (me included)

    • Author: RT
    • Posted on: 2010/06/07
    • At: 20:37

    I’m baffled – using v3.3 on android 2.1. I enter my page and I can scroll the div once – I see touchStart/touchMove/touchEnd events fire. If I try to scroll the div again the whole browser moves up/down, and the touch events do not fire. This did not happen with 3.1. I can’t see what change made my page not work. Any ideas to debug this?

    • It works for me… same android version (HTC Desire). I need more feedback on this. BTW, to solve just place the 2 addeventlisteners in touchstart event in the init phase (just below the addeventlistener(‘touchstart’…) and remove the 2 removeeventlisteners.

    • Author: RT
    • Posted on: 2010/06/08
    • At: 15:51

    I ended up adding the “addeventlistener(‘touchstart’…) ” after the removeeventlisteners in touchEnd and that fixed the problem. Why did you move them out of the init phase, anyway?

    • Author: Jim
    • Posted on: 2010/06/08
    • At: 16:33

    Awesome script first off. Have you had any luck or even thought about though on tackling the iPad iframe scrolling issues? The best description of the problem online without having to type it all in again that I am having is found here:

    http://www.webmanwalking.org/library/experiments/dsp_frames_outer_document.html

    what’s frustrating is they scroll on the iphone but not the ipad and I’ve tried to tackle it with your script with no success and was wondering if you’ve seen it or have any insights on how to make it work?

    thanks!

    • Author: Jim
    • Posted on: 2010/06/08
    • At: 18:51

    Hi I was wondering if anyone who has used iScroll has had any success in implementing a form with drop downs. I am using iscroll, which is awesome, but seem to be having a problem with my form. When you select a drop-down, and the iphone changes ui to allow you to make a selection, the whole scroller div is set out of whack and pushed down so that there is space below the form, but you cannot reach the top anymore, any help would be appreciated, and if I find the answer myself, I’ll reply to myself.

    Thanks
    Jim

      • Author: Jim
      • Posted on: 2010/06/08
      • At: 23:38

      Thought I would further explain what is going on. When i click on a select button, and the apple UI brings up the select bow externally, my form seems to be getting an imaginary padding which pushes the scrollable area down, meaning alot of blank space on the bottom, and being unable to reach the top of the form anymore.

      I would really appreciate any insight, as of right now I am at a lost. Thanks for the great project

      • Author: Adam
      • Posted on: 2010/07/28
      • At: 23:10

      I know exactly what you’re describing. I was also having the same issue with the select dropdown boxes. Here’s how I got the dropdowns to not produce the imaginary padding on select focus (iScroll v3.5). It’s a little hacky. It seems to work nicely on iPhone 3GS iOS4. I haven’t tried other devices. First, add a dummy hidden text box that unfocuses(Blur) itself on it’s onFocus event. On the select element, attach an onBlur event that triggers the focus of the dummy text box.

      Example of the solution (scroll to bottom for select boxes): http://s3.nimblelight.com/upload/iscroll-select/index.html

    • Author: RT
    • Posted on: 2010/06/08
    • At: 19:05

    My horizontal scrolling also stopped working when I went from 3.1 to 3.3. Only change is to replace the older version of the script. It seems that in

    this.scrollX = this.element.offsetWidth > this.scrollWidth ? true : false;

    the offsetWidth is now always equal to the scrollWidth. Any suggestions for this?

    • can you please try the latest version on http://code.google.com/p/iscroll-js/downloads/list ?

      • Author: RT
      • Posted on: 2010/06/08
      • At: 20:57

      That helped a little. Now I can grab a div above my wrapper and make the entire page horizontal scroll , but not the scroller div itself.

      • Author: RT
      • Posted on: 2010/06/08
      • At: 21:59

      *sigh* no – that’s because I made the upper div real wide, nothing to do with iScroll.

    • Author: Matt
    • Posted on: 2010/06/08
    • At: 20:19

    Adding iScroll is causing things to break on the Pre browser. Can you provide tips on graceful degradation of iScroll in browsers that do not support it?

    Even better would be built-in graceful degradation… I fear that many people are developing mobile sites using this and not realizing that they are locking out Pre users when they do so (particularly since you mention the Pre in your introduction).

    • Author: Fiona
    • Posted on: 2010/06/09
    • At: 04:36

    I upgraded from V3.3b1 to 3.3b2 and I found out that the scroll bar is missing….

    BTW, I am doing pages working on both iPhone and Android. I really appreciate your work~!!
    Keep it up~ !

    • Is the scrollbar missing on the live demo for you? If so, I’d need more details (iphone? ipad? Android version?).

      • Author: Fiona
      • Posted on: 2010/06/10
      • At: 03:41

      There’s no scrollbar on the live demo.
      I tested with both iphone and Android (v.1.5.x)

    • On Android 1.5 scrollbars are hidden by default to preserve resources. You can reactivate them by passing the respecting parameter (vScrollbar). On iPhone I can’t really replicate the problem. Can you try to refresh the page a couple of times? Can someone else confirm this issue?

      • Author: Fiona
      • Posted on: 2010/06/11
      • At: 08:11

      Acknowledged the problem~
      Thanks a lot~!!!

  • The latest version does some weird things on my site. If I am using mootools to move an (iscrollable) element down ‘under’ another element, the ‘top’ element jumps around quite a bit.

    I can’t use it for now (I have clients looking at the site) but I was hoping the latest version fixed some of the mis-read content lengths.

    I have several posts in a wordpress blog that are not registering the correct length. You can see it is you go to the site in landscape. Changing orientation fixes the misread, but I don’t want to rely on people to do this if they can’t read a column of text.

    Site is here: http://straathof.acadnet.ca/index2.php Start in landscape and click on ‘Your best five photos for the job’ to see the misread length of content.

    • Are you correctly setting images size? (width/height). Maybe that is the problem. You could also try to disable checkDOMChanges and programmatically refresh() the contents.

    • Author: Francesco
    • Posted on: 2010/06/09
    • At: 17:54

    Hi, I’m developng an iPad project with iScroll and I have a div, on which I applied iScroll, that I don’t want to scroll horizontally.
    I tried setting hScrollBar to false but it doesn’t seem to work.
    Any solution?
    Maybe I’m just made a mistake writing the option, I don’t know.
    Can anyone help me? Thank you

    • If you don’t want to scroll horizontally just make sure that the width of the scrolling div is <= the width of the wrapper.

    • Author: Francesco
    • Posted on: 2010/06/09
    • At: 18:34

    Thank you man! Now I will try ;)

    • Author: Francesco
    • Posted on: 2010/06/09
    • At: 18:34

    Just another question: are you from Italy?
    Your name sounds italian :)

    • Indeed I am italian ;) Ciao!

  • Master Matteo, image sizes in the columns are set to automatic, as are widths. I had them different before, but they stretched when given a distinct value.

    I’ll see what I can do. Perhaps limiting the height and setting the width to automatic will do.

    I’ll also check out the other. I’ve only been at this for three weeks, so all these DOMinatricks things are hard to understand. Kudos on the android, BTW. Can’t wait to hear back from my betatesters.

    • Author: Terry
    • Posted on: 2010/06/09
    • At: 23:53

    Would this help with the notorious background image scrolling problem on iPhone Safari:
    http://stackoverflow.com/questions/3010176/fixed-background-on-iphone-safari

    I mean, could the entire screen be one scroller with a background which doesn’t move?

    • Yes, of course. The background is not actually scrolling.

    • Author: Alex
    • Posted on: 2010/06/10
    • At: 00:14

    Great work, about to upgrade to V3 on my iPhone app, but wanted to know if V3 supports Palm yet.

    • I’d like to have it working on Palm but I don’t have the device. I stopped losing my time on simulators as they are not reliable. If someone wants to sponsor Pre development, please provide me with one device, I’ll be glad to work on it. I already bought half a dozen devices and so far none of my clients asked for Pre compatibility.

    • Author: Fiona
    • Posted on: 2010/06/11
    • At: 10:33

    Just figure out a little problem. I cannot initiate the select action of a dropdown menu in the div bounded by iScroll.

      • Author: Brian
      • Posted on: 2010/06/13
      • At: 23:31

      Also have the same issue.

      • Author: vp
      • Posted on: 2010/06/15
      • At: 19:43

      Yes, I am also facing the same issue. I just replaced the list with drop-down of the simple example, and tried to access from the iPhone browser, it doesn’t allow to select any.

      Could you please share if you have any solution for this issue?

      • Author: Janae
      • Posted on: 2010/06/17
      • At: 18:30

      There were some old comments on the original postings Matteo created for iscroll that had the solution… which is to comment the following lines in the touchStart event, and move them to the touchMove event:

      e.preventDefault();
      e.stopPropagation();

    • Author: Thor
    • Posted on: 2010/06/13
    • At: 12:21

    Is it a possibility to prevent the default event only for the scrollable element instead of the whole document?

    • If you don’t need it, you can remove the prevent default on document touchmove.

    • Author: Chameleon
    • Posted on: 2010/06/14
    • At: 14:18

    Thank you very much for this script, Matteo!
    I got really frustrated on scroll-issues for a long time and I already gave up.
    :-(
    Keep it up and I’m really looking forward to your IE fix!

    • Author: Giorgio
    • Posted on: 2010/06/16
    • At: 18:33

    The work is GREAT! Anyway, I’d really like to get rid of mobile Safari’s menu bar when using this, since it uses a lot of spaces and your script prevents it from auto hiding.
    Any clue on this?

    • The script is not preventing the menu bar to disappear per se. You just need to make your page a bit taller :) I’ll add a demo in the next release (3.4).

    • I also would like to be able to get rid of the menu bar.

      • Author: SinclairZ
      • Posted on: 2010/06/24
      • At: 03:27

      We’re talking about the URL/Search bar at top, right?

    • Author: Donna
    • Posted on: 2010/06/17
    • At: 04:26

    Great fix! The two-finger approach just wasn’t going to work for me – or likely my users!

    Thanks for your efforts!

    • Author: Janae
    • Posted on: 2010/06/17
    • At: 18:27

    First of all, thank you so much for writing this code. It seems to work really well, and has helped me in my web app dev greatly.

    I have a problem that I’ve been trying to get fixed for a while, but I just don’t know what else to try. I’m hoping you have some ideas.

    I’m running my website in full screen mode. I have an iframe that contains a document that holds the scrolling div. Everything works great — except when I have < a > tags in the bottom 44px or so of visible scrolling area.

    I’m using some jquery to handle the ‘click’ event of those tags. I check to see if the scroller was scrolling, and if it isn’t, then I update the source of my iframe with the new URL. For some reason, for any links clicked in the bottom 44px of the visible scrolling area, my click eventhandler always thinks that the scroller has just moved and therefore doesn’t redirect the user. (I’m using the code parent.myScroll.moved to see if the user is scrolling.)

    During my debugging, I added an alert to the beginning of ‘touchStart’ in iscroll.js. That alert would occur for any link higher up on the page, but not towards the bottom.

    If you have the time, I’d really appreciate your help with this. Please e-mail me if you think having the URL to my site would help.

    BTW, I’m using an iPod touch during my development.

      • Author: Janae
      • Posted on: 2010/06/17
      • At: 18:32

      Looks like my comment above didn’t like the html I included. What it should say is in the 3rd paragraph is:

      “… except when I have anchor tags in the bottom 44px or so…”

    • Author: Janae
    • Posted on: 2010/06/17
    • At: 21:42

    Nevermind; I figured out my problem. The page that held the iframe contained a top navigation bar that was 42px high. The page that showed within the iframe (that had the scroller area) didn’t account for the 42px offset when setting up the scrolling area. I moved my top navigation to the page that holds the scroller, and everything works fine.

    I wasn’t sure how to update iscroll.js to account for the 42px offset … any suggestions regarding that would be appreciated because I’d really prefer to have my top nav on the iframe container page.

    • you shouldn’t be using iframes but dynamically load contents with ajax calls.

      • Author: Janae
      • Posted on: 2010/06/17
      • At: 23:30

      I agree. But considering time, money, and the fact that we’re migrating an existing site – this is what we’re doing. Do you have a suggestion on how to offset the scroller those 42px?

      Again, thanks for all your hard work on this project.

    • I’d need to see a demo page