getAttribute(???axis???);
if (axis == ???y???)
(backwards ? fromPage : toPage).style.top = ???100%???;
else
toPage.style.left = ???100%???;
toPage.setAttribute(???selected???, ???true???);
scrollTo(0, 1);
clearInterval(checkTimer);
var percent = 100;
Chapter 3: Implementing the Interface
71
slide();
var timer = setInterval(slide, slideInterval);
function slide()
{
percent -= slideSpeed;
if (percent < = 0)
{
percent = 0;
if (!hasClass(toPage, ???dialog???))
fromPage.removeAttribute(???selected???);
clearInterval(timer);
checkTimer = setInterval(checkOrientAndLocation, 300);
setTimeout(updatePage, 0, toPage, fromPage);
}
if (axis == ???y???)
{
backwards
? fromPage.style.top = (100-percent) + ???%???
: toPage.style.top = percent + ???%???;
}
else
{
fromPage.style.left = (backwards ? (100-percent) : (percent-100)) + ???%???;
toPage.style.left = (backwards ? -percent : percent) + ???%???;
}
}
}
The primary purpose of slidePages() is to emulate the standard iPhone/iPod touch slide animation
effect when you move between pages. It achieves this by using JavaScript timer routines to incrementally
update the style.left property of the fromPage and the toPage . The updatePage() function
(discussed previously) is called inside of a setTimeout routine.
Pages:
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98