The <ons-splitter-side>
element is used as a child element of <ons-splitter>
.
It will be displayed on either the left or right side of the <ons-splitter-content>
element.
It supports two modes: collapsed and split. When it’s in collapsed mode it will be hidden from view and can be displayed when the user swipes the screen or taps a button. In split mode the element is always shown. It can be configured to automatically switch between the two modes depending on the screen size.
The Splitter
is used to display a menu next to the main content. It can be configured to either display in column layout or as a swipeable menu. It is also possible to automatically switch between column layout and a layout with a swipeable menu based on the screen size or any arbitrary condition. In some situations it can be useful to display a column layout on large devices and hide the menu on smaller screens.
The menu is defined using the SplitterSide
component. This component can either be displayed as a column next to the main content or as a swipeable menu. This behavior is controlled using the collapse
property.
To enable opening and closing the menu by swiping the isSwipeable
property must be defined. The side
property is used to specify on which side of the screen the menu is displayed.
The menu can be opened and closed using the isOpen
property. This property only works when the menu is collapsed, since in column layout it is always visible.
In the following example the menu is opened, when the user presses a button. The onClose
property is called when the menu is closed and is used to control the state.
The main content of the screen is put inside the SplitterContent
component. A Page
component should be put as a child of this component.
<Splitter>
<SplitterContent>
<Page>
Main content
</Page>
</SplitterContent
</Splitter>
Name | Type | Description |
---|---|---|
animation |
String
default |
Specify the animation. Use one of overlay , push , reveal or default .
Optional.
|
animation-options | Expression |
Specify the animation’s duration, timing and delay with an object literal. E.g. {duration: 0.2, delay: 1, timing: 'ease-in'} .
Optional.
|
open-threshold |
Number
0.3 |
Specify how much the menu needs to be swiped before opening. A value between 0 and 1 .
Optional.
|
collapse | String |
Specify the collapse behavior. Valid values are |
swipe-target-width | String | The width of swipeable area calculated from the edge (in pixels). Use this to enable swipe only when the finger touch on the screen edge. Optional. |
width | String |
Can be specified in either pixels or as a percentage, e.g. 90% or 200px .
Optional.
|
side |
String
left |
Specify which side of the screen the <ons-splitter-side> element is located. Possible values are "left" and "right" .
Optional.
|
mode | String |
Current mode. Possible values are "collapse" or "split" . This attribute is read only.
Optional.
|
page | String | The URL of the menu page. Optional. Works only during initialization. |
swipeable | Boolean | Whether to enable swipe interaction on collapse mode. Optional. |
Name | Description |
---|---|
animationOptions |
Specify the animation’s duration, timing and delay with an object literal. E.g. {duration: 0.2, delay: 1, timing: 'ease-in'} .
|
swipeable | Whether to enable swipe interaction on collapse mode. |
page | Page location to load in the splitter side. |
pageLoader | |
mode | Current mode. Possible values are “split”, “collapse”, “closed”, “open” or “changing”. |
onSwipe | Hook called whenever the user slides the splitter. It gets a decimal ratio (0-1) and an animationOptions object as arguments. |
isOpen | Specifies whether the menu is opened. |
Signature | Description |
---|---|
open([options]) | Open menu in collapse mode. |
close([options]) | Close menu in collapse mode. |
toggle([options]) | Opens if it’s closed. Closes if it’s open. |
load(page, [options]) | Show the page specified in pageUrl in the right section |
Open menu in collapse mode.
Returns: Resolves to the splitter side element or false if not in collapse mode
Name | Type | Description |
---|---|---|
options | Object | Parameter object. |
options.callback | Function | This function will be called after the menu has been opened. |
Close menu in collapse mode.
Returns: Resolves to the splitter side element or false if not in collapse mode
Name | Type | Description |
---|---|---|
options | Object | Parameter object. |
options.callback | Function | This function will be called after the menu has been closed. |
Opens if it’s closed. Closes if it’s open.
Returns: Resolves to the splitter side element or false if not in collapse mode
Name | Type | Description |
---|---|---|
options | Object |
Show the page specified in pageUrl in the right section
Returns: Resolves to the new page element
Name | Type | Description |
---|---|---|
page | String |
Page URL. Can be either an HTML document or a <template> .
|
options | Object | |
options.callback | Function |
Name | Description |
---|---|
modechange | Fired just after the component’s mode changes. |
preopen | Fired just before the sliding menu is opened. |
postopen | Fired just after the sliding menu is opened. |
preclose | Fired just before the sliding menu is closed. |
postclose | Fired just after the sliding menu is closed. |
swipe | Fired whenever the user slides the splitter. |
Fired just after the component’s mode changes.
Name | Type | Description |
---|---|---|
event | Object | Event object. |
event.side | Object | Component object. |
event.mode | String |
Returns the current mode. Can be either "collapse" or "split" .
|
Fired just before the sliding menu is opened.
Name | Type | Description |
---|---|---|
event | Object | Event object. |
event.cancel | Function | Call to cancel opening sliding menu. |
event.side | Object | Component object. |
Fired just after the sliding menu is opened.
Name | Type | Description |
---|---|---|
event | Object | Event object. |
event.side | Object | Component object. |
Fired just before the sliding menu is closed.
Name | Type | Description |
---|---|---|
event | Object | Event object. |
event.side | Object | Component object. |
event.cancel | Function | Call to cancel opening sliding-menu. |
Fired just after the sliding menu is closed.
Name | Type | Description |
---|---|---|
event | Object | Event object. |
event.side | Object | Component object. |
Fired whenever the user slides the splitter.
Name | Type | Description |
---|---|---|
event | Object | Event object. |
event.ratio | Object | Decimal ratio (0-1). |
event.animationOptions | Object |
If you have any questions, use our Community Forum or talk to us on Discord chat. The Onsen UI team and your peers in the community will work together to help solve your issues.
For bug reports and feature requests use our GitHub Issues page.