> iScroll
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
falseto never show the horizontal scrollbar. The default valuetruemakes the iScroll smartly decide when the scrollbar is needed. Note that if device does not supporttranslate3dhScrollbar is set tofalseby default. - vScrollbar: set to
falseto never show the vertical bar. The default valuetruemakes the iScroll smartly decide when the scrollbar is needed. Note that if device does not supporttranslate3dvScrollbar is set tofalseby default. - bounce: set to
falseto prevent the scroller to bounce outside of boundaries (Android behavior). Defaulttrue(iPhone behavior). - bounceLock:, if set to
truethe scroller stops bouncing if the content is smaller than the visible area. Default:false(as per native iphone scroll). - checkDOMChanges: set to
falseto prevent auto refresh on DOM changes. If you switch off this feature you have to calliScroll.refresh()function programmatically every time the DOM gets modified. If your code makes many subsequent DOM modifications it is suggested to set checkDOMChanges tofalseand to refresh the iScroll only once (ie: when all changes have been done). Defaulttrue. - fadeScrollbar: define wether the scrollbars should fade in/out. Default
trueon iPhone,falseon Android. Set tofalsefor better performance. - momentum: set to
falseto remove the deceleration effect on swipe. Defaulttrueon devices that support translate3d. - shrinkScrollbar: set to
falseto remove the shrinking scrollbars when content is dragged over the boundaries. Defaulttrueon iPhone,falseon Android. It has no impact on performances. - desktopCompatibility: for debug purpose you can set this to
trueto have the script behave on desktop webkit (Safari and Chrome) as it were a touch enabled device. - snap: set to
trueto 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.
elmust be a CSS3 selector. Eg:scrollToElement("#elementID", '400ms'). - scrollToPage(pageX, pageY, runtime): if snap option is active, scrolls to any page.
pageXandpageYcan be an integer orprev/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
fullset totrue, 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.
Thank you for a great script. I have been struggling for about a week trying to get something similar to work. The scrolling is nice and smooth.
Is there a way to make each swipe action to move the scroller a set amount? Say to the beginning of the next page. The Suzuki 50 years site (http://www.suzuki50years.com/) when viewed on the iPad is able to do it using your iScroll.
Thanks again for a great script, and thanks for the reply to my previous question. How would I control the scroll position of the iscroll? Setting the scrollLeft() works in the browser but not on the ipad. :s
you mean scrollTo() ?
Is there a way to only bounce horizontally?
What I want to do is have the scroller div only scroll horizontally, and absolutely no bouncing or scrolling vertically.
Is this a css problem or something that can be fixed with javascript?
**FACEPALM** it was a CSS issue. My bad.
Thanks for an amazing open source script. Its incredible.
Keep the web free.
Hi, I’m trying to do the same thing. Could you please let know you how this was done?
Thanks.
Okay I got it to work as well. Based on the above code, the trick is to set a width on #scroller, and eventually hide the horizontal scrollbar. Cheers!
It seems that I cannot use the tag from with the on the iPhone. Is there a way to cause the spinning wheel to appear when the user needs to change his/her options in a select menu?
It seems that I cannot use the select tag from within the #scroller div on the iPhone. Is there a way to cause the spinning wheel to appear when the user needs to change his/her options in a select menu?
Hi Matteo, nice to know that italians make absolutely awesome stuffs.
There is a possibility to scroll to the next (or previous) element by using the touchmove event?
Thanks again
a bit vague
please provide more details
Thanks for answer, i want to scroll to the next element by touching the right part of the scroller viewport. Till now i have intercepted the touch in the right area but i dunno how to tell to iScroll to go to the next (or previous) element.
ex. im on the first that has a 1024px width. I touch it and automatically iScroll go to the second
^_^
Thanks
You should be able to use scrollTo() for that, but you have to find the element position by yourself. BTW, scroll to object and position snap are two features I’m working on right now.
so i can use:
var scroller = new Scroller(id)
scroller.scrollTo(newX, newY);
where X and Y are the new positions? So if i have a 1024 element i can use:
scroller.scrollTo(1024, newY);
scroller.scrollTo(2048, newY);
and so on
Cheers
Huh,
I tried with 3.4 with my code base to check if the drop down list feature in the scroll area …Still it didn’t work with touch event. May be it is time to check back the doctyper, where it is working with drop downs in scroll content area using iphone. Only thing I need to see to fix the landscape to potrait footer fix.
http://doctyper.com/archives/200808/fixed-positioning-on-mobile-safari/
Hi Matt,
I have a page that uses and “iframe” tag, basically, when you view it on a normal browser all content of the page are displayed well. But on the iphone/ipad they are not displayed properly.
Below are the codes that I use:
ASPX Part:
This part of code calls the code behid.
VB Part:
If Not keyword Is Nothing Then
taleoDetails.Text = “”
Else
keyword = “10180/jobsearch.ftl?lang=en” & campaignString
taleoDetails.Text = “”
End If
CSS Part:
#IBN_mainTable2
{
background-color:#FFFFFF;
margin:-639px auto 0 auto;
top:0px;
border: solid 1px white;
height: 570px;
width: 780px;
overflow: auto;
text-align:left;
}
My problem here is that the part of the iframe is not scrollable on ipad/iphone.
Please advice…
Thanks in advance..
below is the missing part of the VB.
VB Part:
If Not keyword Is Nothing Then
taleoDetails.Text = “”
Else
keyword = “10180/jobsearch.ftl?lang=en” & campaignString
taleoDetails.Text = “”
End If
Sorry for this, I am having a problem on embedding the vb part which is the most important thing of my code. maybe i can send it to your email add if its ok with you.
Great small script, been looking all over for this. But the css in the examples/simple/index.html differs from the live demo in one way, making it funky and too wide:
#scroller { … width: 1000px; … }
In the live demo it’s 100%, and that makes it scroll only up/down which is the correct behavior i think.
Thanks for a super script, looking forward to my own iPhone app soon..
Thanks for your report Niclas… too many late-night-programming hours I’m afraid
Hi again Matteo! I’ve put it on the home screen of the iPhone to make it go fullscreen, and when doing that, the header gets partly hidden behind the operator/clock status-bar.
I can fix this by doing #header {padding-top: 20px;} but then it looks weird when viewing it normally in Safari, the header gets a padding above the text.
Do you know if it’s possible to detect if it’s fullscreen and adjust the placement of the header to always make it cover the entire screen?
Although I’ve seen some other apps forcing the user to start it in homescreen-mode using “window.navigator.standalone”. If this is true, then it’s started from home screen. Then I don’t have to worry about how it looks from inside Safari.
Not sure what happens on Android though with this parameter… I wouldn’t exclude Android users, that’s just rude..
Also, I have some trouble figuring out how to actually put links on the items in the list:
Item in list
How do I make this execute? I figure I have to do something in the click.addEventListener, but not sure what to do.
I want a click here to show another page with a css 3d transform (or at least slide), but I’ve only tried this with JQTouch, where you made a href=”#page”, which showed another page. Can you give me some hints on how to proceed to make a complete page out of this?
I will probably use JQuery to load the next page with Ajax, but first I have to break out of this list..
I really like the idea of not having to use a big bloated framework, but I guess I have to do some of the work myself to make it work..
In my opinion the best way to handle clicks is to add an event listener (eg: “click”) directly to the LIs. This way you don’t have to add extra markup. You could of course also use anchors (< a >), it should work as well.
Regarding your question about page-flip, consider that I’m going to release a micro-framework just for that.
This is brilliant! Thanks so much Matteo!
Any idea why my version gets stuck if I’m at the bottom of a page and rotate my iPhone’s from portrait to landscape mode?
http://tsl.pomona.edu/new/mobile3/
hi
i was just searching for a solution for the problem but the “live demo” simply doesn’t work on my iphone. any comments on this?
thanks
robert
Sorry, my fault (wrong path in the latest update). Just reload
Hi Matt,
I have a page that uses and “iframe” tag, basically, when you view it on a normal browser all content of the page are displayed well. But on the iphone/ipad they are not displayed properly.
Below are the codes that I use:
ASPX Part:
This part of code calls the code behid.
VB Part:
If Not keyword Is Nothing Then
taleoDetails.Text =
Else
keyword = “10180/jobsearch.ftl?lang=en” & campaignString
taleoDetails.Text =
End If
CSS Part:
#IBN_mainTable2
{
background-color:#FFFFFF;
margin:-639px auto 0 auto;
top:0px;
border: solid 1px white;
height: 570px;
width: 780px;
overflow: auto;
text-align:left;
}
My problem here is that the part of the iframe is not scrollable on ipad/iphone.
Please advice…
Thanks in advance..
What about onscroll events, is it possible to load content dinamically when scrolling with iscroll?
Nice idea. Not the easiest thing, though
Is there now a bug in Chrome, where you can’t set click events on elements?
I have anchor links that i’m attaching click events ( via jquery ) now the events don’t work with the latest 2 code updates. They work fine in Safaria and FF, but not in Chrome 5.0.375.70
I’ll check this out. Thanks for your report.
to all: please consider reporting bugs to http://code.google.com/p/iscroll-js/issues/list
Hi Matteo,
Great plugin, I have a question. Should the destroy() function reset all variables(x,y’s) that the plugin uses? I’m toggling a div and it seems that calling destroy() does not “re init” the values. Any Thoughts?
myScroll = myScroll.destroy(true);
should reset everything.
I tried the destrory(true) and it remove my div from the DOM all together. I ended up working around this issue with some CSS and Jquery. Thanks again.
myScroll = myScroll.destroy() without ‘true’ does not destroy the DOM.
correct but I don’t think destroy() was having a problem. I think something else was going on, thanks again.
I’ve made some kind of “onscroll” event adding some code to the “touchEnd” function:
if (this.maxScrollY == this.y){
//load more content
}
Maybe you can implement something better using this idea, Matteo.
Thanks for the script.
BTW, could someone fix the “select” and other form fields problem? I need to make them work with iscroll.
is there a working way to have the style code placed in a css?
because when i place the styles into a css the whole style wont load on the iphone, in firefox however it shows up.
any idea why?
plus i get allways two js errors:
WebKitCSSMatrix is not defined
[Break on this error] var has3d = (‘m11′ in new WebKitCSSMatrix()),
and
iScroll is not defined
[Break on this error] myScroll = new iScroll(‘scroller’);
another problem, scrollTo doensn’t work on the iphone/pad, and on firefox it instantly jumps to the designation rather than using the milliseconds parameter to scroll smoothly, any suggestions?
ps: im using scrollTo to scroll horizontal
firefox is not currently supported by iscroll (the script is targeted to webkit mobile). scrollTo() works flawlessly on ipad/iphone. Are you using negative values?
ok, to sum it up:
as “WebKitCSSMatrix is not defined” and “iScroll is not defined” the “myScroll.scrollTo(-300,0)” doesn’t work on any normal browsers. i managed to get it working now with this syntax on iphone and added the “scrollTo(300,0)” to have at least the same position change on firefox, ie. still this is a buggy solution for normal browsers.
what i really dont understand is why the styles cant be placed in css. can you comment please.
thanks
syntax: scrollTo(x, y, time). time must be a string. eg: “200ms”. iScroll sets just the bare minimum styles it needs to operate. If you want to place everything in a stylesheet you are free to do so
just comment the setAttribute and put everything in a css.
Hi Matteo,
First of all, thanks for the wonderful job. You rock, man !
I’ll be glad to credit you in my next project.
I have a problem I can’t figure out to workaround, maybe you can help if you have some time (?!)
My scrolling container has a variable width and height (triggered on the window.onresize event). Everything works fine when i resize the window, but in case of a change of device orientation (iPad), the scrolling zone doesn’t refresh -_until_ i tap on it.
I tried to call iScroll.refresh(), but this does’nt work, I still have to tap on it to force repainting. The point is, it works fine with classical resizing, but fails in this special case.
Any idea ?
Thanks a lot, anyway.
Ciao
Jean-Philippe
Try the following. Uncomment line 50, add before line 90:
case 'orientationchange':If it doesn’t work change line 92 (current line 91) to:
var that = this; setTimeout(function() { that.refresh(); }, 0);
Let me know if it works.
Should be fixed in latest update (3.4.4)
Thanks Matteo.
I’l test it tonight, and let you know if it works.
Have a nice day
BTW, I’m already running 3.4.4.
Did you mean 3.4.5 ?
I released 3.4.4 today…
Matteo,
Sorry to say that 3.4.4 doesn’t fix it,it’s even getting “worse”:
ie;, taping on the screen doesn’t refresh correctly from now.
I have to initiate a scrolling movement to correctly repaint the content of my div.
I’m going to give a deeper look at your code to find a tweak, but it sounds like a css issue, maybe also in my code.
I’ll let you know if I can manage it to work properly after a page flip.
Ciao
Jean-Philippe
Good news !
Last problem was due to a combination of a cache issue (it kept and older version of iScroll) and a Dojo side-effect.
I changed it for mooTools, and even if I have to recode my main Widgets, it works now like a charm.
Thanks again Matteo.
Huhh !
Should be a time zone problem between France and Italia…
I’m so happy to use jscroll that I travelled in time to get 3.4.4 before you write it !
That’s what you can call a _real_ fan
Ok, I am missing something. In the demo, the page is locked with exception to the scroller. No matter what I do, dragging the the header or footer still drags and bouonces the whole page vertically.
What device and os version?
iPad Safari
I also wanted to say that 3.4.4 runs much smoother than erlier version on the iPad. Nice work
Reading over my initial question, I am not sure I was very clear.
I like what the demo is doing by not allowing the whole page to be scrolled vertically. On the page I have developed, if I swipe outside the scroller, then the whole page drags up or down and then snaps back.
I am looking for the behavior that is demonstrated is the demo where swiping outside the scroller does not begin to try and scroll the whole page.
Thanks again.
p.s. I am guessing it is something noobish on my end.
I was just wondering if I could use this (or the extension for jQtouch) and still maintain the support to hide location bar. It doesn’t seem to work. Anyone have any ideas?
This is absolutely the most frequently asked question. If the objects on the page don’t exceed the page height the URL bar won’t hide. I’ll make an example on how to hide the url bar. Promised.
Matteo, while you’re working on an example, can you explain it briefly, either in pseudo-code or plain English?
Is there a way to always show the scrollbars? Even if the user currently is not scrolling.
not yet, but it’s a nice feature
Ever think of the feature “snap content to bounds”? when press release, the content automatically scroll to bounds. Think it’s a pretty common req.
… Actually I already have a working “snap scroll” script. Just need to tidy it up. http://vimeo.com/12830018
Hi Matteo,
I mentioned on twitter that I added disable/enable functions. I considered forking your code but this is pretty minimal stuff. Here’s what I did:
////// in the main function
(function(){
function iScroll (el, options) {
this.disabled = false; // Added a flag for disabled
////// inside touchMove:
if (this.dist > 5) {
if(!this.disabled) { // check the flag
this.setPosition(newX, newY);
this.moved = true;
}
}
////// and finally, added these 2 functions to your prototype
disable: function() {
this.disabled = true;
},
enable:function() {
this.disabled = false;
}
/////// you can use it like this:
myScroll = new iScroll(‘element’);
myScroll.disable();
myScroll.enable();
In my use-case I needed to scroll horizontally and when clicking an item inside the scroll area I needed it to pop out of the div and disable scrolling until you triggered it to return to its position. I’d love to show you!
Thanks again for this wonderful script!
Thanks for sharing, you could also try to just stopPropagation() to your touchStart event. It should work.
Hey Matteo,
For some reason after scrolling a bit down a page and then selecting a text field, the ability to edit the text does not work. The options to cut,copy,paste or select the text cannot be done.
(iphone os4, iscroll 3.4.5)
Suppose you want to add two scrollers on the same html, you just make two iScroll obj? Does this object use a lot of memory?
“yes” to the first question and “no” to the second. I’m also baking a demo that uses just one iScroll for multiple objects.
Can you confirm that its still possible to do:
iScroll.refresh();
I’ve tried, but looks like you are unable to do so… as it comes back as undefined.
Seems to work for me
Hi Matteo
You’re making a great work for us.
I’ve two questions for which I couldn’t find solution after a week playing with iScroll.
1. I’ve noticed that when I change orientation of Iphone (3g with ios4) to landscape and back, the iScroll stops working
2. Is there a way to have some notification from iScroll that it has been initialized to the given objects? I’ve tried to add a ‘ready’ class name to the object at the end of function iScroll (line 64), but it does’t seem to help. I would need it because after loading the page I have to set display: none to some elements for which I would like to use iScroll.
Thanks again
And keep up working
1. Unfortunately I cannot test on 3G+ios4, but it seems to work on every other os/device combination. 2. Why not calling your function on window load?
I have an iPhone 3G with iOS4 installed and after changing orientation to landscape and back, it still works. So it’s probably a bug on your side.
I have a problem. Onclick events attached to LI elements inside an iScroll-ed UL element (i.e. child elements) does not get fired on desktop. Everything’s OK on iPhone.
I tried changing like 76 to the following and it seems to work pretty fine.
if (!e._fake && isTouch) {
Awesome script! But I noticed it doesn’t allow users to scroll back up the page if they happen to click on an anchor tag that jumps to another point in the document. The jump will work as normal, but if you try to scroll up, it will bounce back down again. I’m assuming it’s because when you click the anchor tag which jumps the document position, iScroll still thinks the position is zero so it doesn’t let you scroll back up (i.e. negative).
You have to find object position and scroll with scrollTo() (not with anchor).
Excellent script!
Please, release your snap-iScroll need it bad!
Ivan
A few things I’m having issues with:
1) When I add in functions.js and style.css (version css 5.04) from iWebkit the footer doesn’t line up correctly due to conflicting styles. What is the best way around this?
2) When using li class=”menu” (from iWebkit, again version 5.04) when I scroll, the menu item li, that is in the location where I first put my finger to start scrolling, highlights blue. This has been a problem for me in all the versions of iscroll.js that I’ve tried. Is it a known bug or something I’m doing wrong?
Normal li class=”textarea” scroll fine without highlighting, but as soon as I add the menu class things act strange.
1) Just rename the footer ID (and related iScroll styles and JS if you use my code to resize on orientation change)
2) I’m sorry I don’t use iWebkit, but it seems something related to iWebkit, not iScroll.
Matteo,
Thanks for the info! After a few style conflict changes I was able to get this working well with iWebKit. I still have a few tweeks to make but overall its working great. Thanks so much for all your hard work.
Hi. This technique looks really nice, but it DISABLES the possibility to pinch&zoom. Is there a way to make this feature working again?
I have been able to set up a page with scrolling features and a div – using your method – that has independent scrolling features, I can post the code if you like.
Best,
When i use iScroll , I lost text copy/paste function on my iPad….