开发者

iPad split view in HTML like Gmail / Ymail?

开发者 https://www.devze.com 2023-01-16 14:15 出处:网络
As we all know, iPad do not support the <frame> element, but both Gmail and Ymail could do something similar by crea开发者_StackOverflow社区ting a 2pane style , and the navi pane (left one) coul

As we all know, iPad do not support the <frame> element, but both Gmail and Ymail could do something similar by crea开发者_StackOverflow社区ting a 2pane style , and the navi pane (left one) could scroll (in ipad style). May I ask if anyone do have the idea how it created?

Thank you very much.


I don't actually know for sure how they've done it (I can't seem to reach mobile gmail in a desktop browser, and I can't find a view-source feature on my iPad) but I suspect that it's not as complicated as it looks.

Keep in mind that in a regular browser, when there is too much content we get a scrollbar. That's not how the iPad renders long pages. On the iPad, if there is too much content we never get a scrollbar, scrolling is achieved by sliding the content up and down. So what we should imagine is that this is two panes with scrollbars, because that's how it would show up in a normal browser.

From there, it's a much simpler problem. It's probably just two divs floated in a standard two-column layout, each with their overflow set to scroll. Something super-basic, like:

<div>
    {the nav list of emails goes here}
</div>
<div>
    {the currently-open email goes here}
</div>

<style>
div {
    float: left;
    width: 50%;
    overflow-y: scroll;
}
</style>

There's probably something fancy in there to make each div consume 100% of the available height (it's probably not as simple as height: 100%) but already if either div contains enough content, we'll get individual vertical scrollbars which the iPad will hide, giving us that neat sliding-scroll gesture instead.


I've tested a few of my own apps which were build back in time with Frames. They all worked "normally" are you sure you didnt use the wrong Doctype for your HTML?


Individual block elements with overflow-y:scroll are only scrollable with two fingers on the iPad. That's just the way it is.

So how does Gmail do it differently? Manually, with JavaScript, reacting to various touch events.

Your best bet at the moment is to use iScroll. This used to be a bit un-smooth (compared to Gmail and others' implementations), but the latest version is really good. Try their demo.

It works on iPad/iPhone, Android, and you can even use it in a normal browser using your mouse. It has the nice elastic effect when you reach the top/bottom of a scrollable area, and it has the iOS-style scroll indicator thing that appears on the right during a scroll. It's almost as smooth as scrolling on a native app.

By the way, if you want to examine an iPad-specific website's source, the easiest way is using Safari (I've tried this on 5.0.3 for Mac, but probably works on other platforms too). Turn on the Develop menu (Safari>Preferences>Advanced), then you can set your User Agent to iPad.

You can do the same thing in Firefox, posing as an iPad, but I often find the websites look completely broken. I think this is because many iPad/Android-specific websites rely on Webkit features that aren't present in Gecko. In fact, Apple's iPad guide site, which also uses a two-pane scrolling technique, simply rejects you if you're not (a) sending an iOS User Agent string and (b) using Webkit. And Chrome doesn't have an easy way to change your User Agent string. So Safari is the easiest way to examine these kind of sites.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号