Auto-scrolling on the iPhone

J

Jonas Smith

I have on my website, which feature a lot of reading material, a script
to autoscroll a page while reading so that a reader doesn't need to hit
the space bar or page down to read. It uses setinterval for a function
to scroll one pixel at a time.

That script doesn't work on the iPhone. I've been looking for a while
and nobody has pointed me in the right way.

The problem is that the iphone creates a window as tall as the document
and when you scroll, you move the window instead of scrolling the
document within the window.

Anybody has any suggestion? working sample code?

Thanks in advance.
 
T

Thomas 'PointedEars' Lahn

Jonas said:
I have on my website, which feature a lot of reading material, a script
to autoscroll a page while reading so that a reader doesn't need to hit
the space bar or page down to read. It uses setinterval for a function
to scroll one pixel at a time.

That script doesn't work on the iPhone. I've been looking for a while
and nobody has pointed me in the right way.

The problem is that the iphone creates a window as tall as the document
and when you scroll, you move the window instead of scrolling the
document within the window.

Anybody has any suggestion? working sample code?

http://www.catb.org/~esr/faqs/smart-questions.html


PointedEars
 
D

Dr J R Stockton

Sun said:
Anybody has any suggestion?

I suppose that you start this by means of a control. You could,
***possibly***, using either a different control for the iPhone or
iPhone detection code, insert at the top a large DIV and scroll by
steadily reducing its height. PERHAPS. (Ordinary users could still
have the DIV, 1 px high).
 
D

David Mark

In comp.lang.javascript message <[email protected]>, Sun, 13
Dec 2009 20:53:14, Jonas Smith <[email protected]> posted:




I suppose that you start this by means of a control.  You could,
***possibly***, using either a different control for the iPhone or
iPhone detection code,

No iPhone detection code is needed. You call scrollBy and check the
scroll position reported against the expected result. If it doesn't
do what it is supposed to do, emulate it.

According to MSDN:-

"Causes the window to scroll relative to the current scrolled position
by the specified x- and y-pixel offset."

http://msdn.microsoft.com/en-us/library/ms536728(VS.85).aspx

So you get the scroll position, add your offset and then use
scrollTo. You could even skip the feature testing and do this for all
browsers:-

myScrollBy = function(x, y, win) {
if (!win) {
win = window;
}
var sp = getScrollPosition(win); // Scene missing
win.scrollTo(x + sp[0], y + sp[1]);
};
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,235
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top