shadow Contentコンポーネントは、スクロール可能領域を制御するいくつかの便利なメソッドを備えた、
使いやすいコンテンツ領域を提供します。
1つのビューに表示できるコンテンツは1つだけです。
Contentは、他の多くのIonicコンポーネントと同様に、 CSS Utilities で提供されるグローバルスタイルを使用するか、CSSおよび使用可能な CSS Custom Properties を使用して個別にスタイル設定することによって、padding
や margin
などを変更するようにカスタマイズできます。
コンテンツは、ページ内の唯一のトップレベル・コンポーネントとすることも、ヘッダー 、フッター 、またはその両方と一緒に使用することも可能です。ヘッダーやフッターと一緒に使用すると、残りの高さを埋めるようにサイズが調整されます。
Fullscreen Content デフォルトでは、コンテンツは ヘッダー と フッター の間のスペースを埋めますが、それらの背景にまわることはありません。例えば、ヘッダーとフッターのどちらかに translucent
プロパティを設定した場合や、ツールバーに opacity
を設定した場合など、特定のケースでは、コンテンツをヘッダーとフッターの後ろにスクロールさせることが望まれるかもしれない。これは、コンテンツの fullscreen
プロパティを true
に設定することで実現することができます。
スクロール可能な領域の外側に要素を配置するには、fixed
スロットに割り当てます。そうすることで、その要素はコンテンツの左上に絶対位置 されます。要素の位置を変えるには、CSSのtop, right, bottom, left プロパティを使ってスタイルを設定することができます。
コンテンツには メソッド が用意されており、これを呼び出すことでコンテンツを下、上、または特定のポイントにスクロールさせることができます。これらのメソッドには duration
を渡すことができ、瞬時に位置を変更するのではなく、スムーズに移行することができます。
スクロールイベントは、パフォーマンス上、コンテンツに対してデフォルトで無効化されています。しかし、scrollEvents
を true
に設定することで、有効にすることができます。これは、 スクロール イベント を聞く前に必要です。
interface ScrollBaseDetail { isScrolling : boolean ; }
Copy interface ScrollDetail extends GestureDetail , ScrollBaseDetail { scrollTop : number ; scrollLeft : number ; }
Copy 必須ではありませんが、ionScrollStart
と ionScrollEnd
イベントをより強く型付けするために、CustomEvent
インターフェースの代わりにこのインターフェースを利用することが可能です。
interface ScrollBaseCustomEvent extends CustomEvent { detail : ScrollBaseDetail ; target : HTMLIonContentElement ; }
Copy 必須ではありませんが、ionScroll
イベントをより強く型付けするために、CustomEvent
インターフェースの代わりにこのインターフェースを利用することが可能です。
interface ScrollCustomEvent extends ScrollBaseCustomEvent { detail : ScrollDetail ; }
Copy Description The color to use from your application's color palette. Default options are: "primary"
, "secondary"
, "tertiary"
, "success"
, "warning"
, "danger"
, "light"
, "medium"
, and "dark"
. For more information on colors, see theming . Attribute color
Type "danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record<never, never> | undefined
Default undefined
Description If true
and the content does not cause an overflow scroll, the scroll interaction will cause a bounce. If the content exceeds the bounds of ionContent, nothing will change. Note, the does not disable the system bounce on iOS. That is an OS level setting. Attribute force-overscroll
Type boolean | undefined
Default undefined
Description If true
, the content will scroll behind the headers and footers. This effect can easily be seen by setting the toolbar to transparent. Attribute fullscreen
Type boolean
Default false
Description Because of performance reasons, ionScroll events are disabled by default, in order to enable them and start listening from (ionScroll), set this property to true
. Attribute scroll-events
Type boolean
Default false
Description If you want to enable the content scrolling in the X axis, set this property to true
. Attribute scroll-x
Type boolean
Default false
Description If you want to disable the content scrolling in the Y axis, set this property to false
. Attribute scroll-y
Type boolean
Default true
Name Description ionScroll
Emitted while scrolling. This event is disabled by default. Set scrollEvents
to true
to enable. ionScrollEnd
Emitted when the scroll has ended. This event is disabled by default. Set scrollEvents
to true
to enable. ionScrollStart
Emitted when the scroll has started. This event is disabled by default. Set scrollEvents
to true
to enable.
Description Get the element where the actual scrolling takes place. This element can be used to subscribe to scroll
events or manually modify scrollTop
. However, it's recommended to use the API provided by ion-content
: i.e. Using ionScroll
, ionScrollStart
, ionScrollEnd
for scrolling events and scrollToPoint()
to scroll the content into a certain point. Signature getScrollElement() => Promise<HTMLElement>
Description Scroll by a specified X/Y distance in the component. Signature scrollByPoint(x: number, y: number, duration: number) => Promise<void>
Description Scroll to the bottom of the component. Signature scrollToBottom(duration?: number) => Promise<void>
Description Scroll to a specified X/Y location in the component. Signature scrollToPoint(x: number | undefined | null, y: number | undefined | null, duration?: number) => Promise<void>
Description Scroll to the top of the component. Signature scrollToTop(duration?: number) => Promise<void>
Name Description background
The background of the content. scroll
The scrollable container of the content.
Name Description --background
Background of the content --color
Color of the content --keyboard-offset
Keyboard offset of the content --offset-bottom
Offset bottom of the content --offset-top
Offset top of the content --padding-bottom
Bottom padding of the content --padding-end
Right padding if direction is left-to-right, and left padding if direction is right-to-left of the content --padding-start
Left padding if direction is left-to-right, and right padding if direction is right-to-left of the content --padding-top
Top padding of the content
Name Description `` Content is placed in the scrollable area if provided without a slot. fixed
Should be used for fixed content that should not scroll.