<tap-page>
移动端应用的页面布局,带有页头页脚插槽、安全区域内边距和下拉刷新。
内容在页面自身中滚动,并延伸到页头页脚下方,内边距使内容不被它们遮挡。
不要再添加滚动容器,需要时使用 scrollElement。
Example
import '@mantou/tap-ui/elements/page';
import '@mantou/tap-ui/elements/navbar';
import '@mantou/tap-ui/elements/content';
const onRefresh = ({ detail: done }: CustomEvent<() => void>) => {
fetchData().then(done);
};
html`
<tap-page refreshable @refresh=${onRefresh}>
<tap-navbar slot="header" title="Chats"></tap-navbar>
<tap-content>...</tap-content>
<tap-tabbar slot="footer" .items=${tabs}></tap-tabbar>
</tap-page>
`;使用 floatheader 让页头浮在内容之上,内容滚动前导航栏保持透明。
API
TapPageElement
Content scrolls in the page itself and runs under the header and footer;
padding keeps it clear of them, so height: 100% children fill the area between the bars.
Don't add another scroll container, use scrollElement instead.
Absolutely positioned children ignore that padding and end up under the bars,
so keep them in flow or inside an in-flow wrapper.
Shadow DOM; Extends TapVisibleBaseElement
TapPageElement Instance Properties
| Property(Attribute) | Reactive | Type | Description |
|---|---|---|---|
floatheader(floatheader) |
Yes | boolean |
Header overlays content; navbar stays transparent until content scrolls You need to manually handle the top safe area inset for the page content. |
refreshable(refreshable) |
Yes | boolean |
Enable pull-to-refresh on the main scroll area |
loading(loading) |
Yes | boolean |
|
disableNavigation(disable-navigation) |
Yes | boolean |
|
trackVisibility(track-visibility) |
Yes | boolean |
|
pullThreshold(pull-threshold) |
Yes | number |
|
refresh |
Emitter<() => void> |
Fired when pull exceeds the threshold. Call detail() (done) when loading finishes so the indicator can dismiss. |
|
navigationGesture |
Emitter<{ pan?: PanEventDetail; swipe?: SwipeEventDetail; end?: PointerEvent }> |
||
get scrollElement |
HTMLElement | undefined |
The scroll container of the page content, e.g. to keep a chat scrolled to the bottom | |
get contentHeight |
number |
Measures the bars directly, the main insets are only set after the first resize observation |
TapPageElement Other
| Type | Value |
|---|---|
| Event | refresh, navigation-gesture |
| Slot | header, footer |
| Part | main, refresh |
| CSS State | dim, fullscreen |
TapVisibleBaseElement
Extends GemElement
TapVisibleBaseElement Instance Properties
| Property(Attribute) | Reactive | Type | Description |
|---|---|---|---|
show |
Emitter |
||
hide |
Emitter |
||
fullShow |
Emitter |
Fired when the element becomes visible and entirely within the viewport, e.g. a page whose enter animation has finished. |
|
intersectionRoot |
Yes | Element | Document |
|
intersectionRootMargin |
Yes | string |
|
trackVisibility(track-visibility) |
Yes | boolean |
|
delay(delay) |
Yes | number |
TapVisibleBaseElement Other
| Type | Value |
|---|---|
| Event | show, hide, full-show |
| CSS State | visible, full-visible |
