Usage
Typescript Import Format
//This namespace exports multiple static methods or members. To import
import * as OffcanvasUtils from "ojs/ojoffcanvas";
//Now you can access the methods as OffcanvasUtils.methodName and so on
For additional information visit:
Styling Classes
-
.oj-offcanvas-inner-wrapper
-
Applied to the inner wrapper of the page level offcanvas.
Deprecated:
Since Description 6.0.0
Offcanvas inner wrapper is no longer supported. -
.oj-offcanvas-outer-wrapper
-
Applied to the outer most element of the offcanvas.
-
.oj-offcanvas-overlay-shadow
-
Add this marker class to an overlay offcanvas to show a drop shadow when it is open.
-
.oj-offcanvas-page
-
Applied to the outer wrapper of the page level offcanvas.
-
Category: Off-canvas Edge
-
Specifies the default for OffcanvasUtils static methods when applying the offcanvas on the given edge.
Classes:
-
.oj-offcanvas-start
-
.oj-offcanvas-end
-
.oj-offcanvas-top
-
.oj-offcanvas-bottom
-
Methods
-
(static) close(offcanvas) : {Promise.<boolean>}
-
Hides the offcanvas by sliding it out of the viewport. This method fires an ojbeforeclose event which can be vetoed by attaching a listener and returning false. If the close is not vetoed, this method will fire an ojclose event once animation has completed.
Parameters:
Name Type Description offcanvas
Object An Object contains the properties in the following table. - See:
Properties:
Name Type Description offcanvas.selector
string Document selector identifying the offcanvas element Returns:
A promise that is resolved to boolean true when all transitions have completed. The promise is rejected if the ojbeforeclose event is vetoed.
- Type
- Promise.<boolean>
-
(static) open(offcanvas) : {Promise.<boolean>}
-
Shows the offcanvas by sliding it into the viewport. This method fire an ojbeforeopen event which can be vetoed by attaching a listener and returning false. If the open is not vetoed, this method will fire an ojopen event once animation has completed.
Upon opening a offcanvas, focus is automatically moved to the first item that matches the following:
- The first element within the offcanvas with the
autofocus
attribute - The first
:tabbable
element inside the offcanvas - The offcanvas itself
Parameters:
Name Type Description offcanvas
Object An Object contains the properties in the following table. - See:
Properties:
Name Type Argument Description offcanvas.autoDismiss
'focusLoss' | 'none' <optional>
close behavior, valid values are focusLoss and none. If autoDismiss is default(focusLoss) then any click outside the offcanvas will close it. offcanvas.content
string Document selector identifying the main content. offcanvas.displayMode
'push' | 'overlay' <optional>
how to show the offcanvas, valid values are push or overlay. Default: defined by theme. offcanvas.edge
'start' | 'end' | 'top' | 'bottom' <optional>
the edge of the offcanvas, valid values are start, end, top, bottom. This property is optional if the offcanvas element has a "oj-offcanvas-" + class specified. offcanvas.modality
'modal' | 'modeless' <optional>
The modality of the offcanvas. Valid values are modal and modeless. Default: modeless. If the offcanvas is modal, interaction with the main content area is disabled like in a modal dialog. offcanvas.selector
string Document selector identifying the offcanvas element. offcanvas.size
string <optional>
size width or height of the offcanvas: width if edge is start or end and height if edge is to and bottom. Default to the computed width or height of the offcanvas. Returns:
A promise that is resolved to boolean true when all transitions have completed. The promise is rejected if the ojbeforeopen event is vetoed.
- Type
- Promise.<boolean>
- The first element within the offcanvas with the
-
(static) setupPanToReveal(offcanvas) : {void}
-
Setup offcanvas for pan to reveal. This method adds a touch listener to handle revealing the offcanvas as user pans on the outer wrapper. The following events are fired by this method: ojpanstart - fired when pan to reveal gesture initiated by the user. The event includes the direction and distance of the pan. If it is vetoed then pan to reveal is terminated ojpanmove - fired as user continues the pan gesture. The event includes the direction and distance of the pan. ojpanend - fired when pan to reveal gesture ends. The event includes the direction and distance of the pan. If it is vetoed then the offcanvas will be closed.
Parameters:
Name Type Description offcanvas
Object An Object contains the properties in the following table. - See:
Properties:
Name Type Argument Description offcanvas.edge
'start' | 'end' | 'top' | 'bottom' <optional>
the edge of the offcanvas, valid values are start, end. This property is optional if the offcanvas element has a "oj-offcanvas-" + class specified. offcanvas.selector
string Document selector identifying the offcanvas element offcanvas.size
string <optional>
size width of the offcanvas. Default to the computed width of the offcanvas. Returns:
- Type
- void
-
(static) setupResponsive(offcanvas) : {void}
-
Setup offcanvas for the responsive layout. This method adds a listener based on the media query specified in offcanvas.query. When the media query matches the listener is called and offcanvas behavior is removed. When the media query does not match the listener is called and off canvas behavior is added.
Parameters:
Name Type Description offcanvas
Object An Object contains the properties in the following table. - See:
Properties:
Name Type Argument Description offcanvas.edge
'start' | 'end' | 'top' | 'bottom' <optional>
the edge of the offcanvas, valid values are start, end, top, bottom. This property is optional if the offcanvas element has a "oj-offcanvas-" + class specified. offcanvas.query
string | null the media query determine when the offcanvas is fixed inside the viewport. offcanvas.selector
string Document selector identifying the offcanvas element Returns:
- Type
- void
-
(static) tearDownPanToReveal(offcanvas) : {void}
-
Removes the listener that was added in setupPanToReveal. Page authors should call tearDownPanToReveal when the offcanvas is no longer needed.
Parameters:
Name Type Description offcanvas
Object An Object contains the properties in the following table. - See:
Properties:
Name Type Description offcanvas.selector
string Document selector identifying the offcanvas element Returns:
- Type
- void
-
(static) tearDownResponsive(offcanvas) : {void}
-
Removes the listener that was added in setupResponsive. Page authors should call tearDownResponsive when the offcanvas is no longer needed.
Parameters:
Name Type Description offcanvas
Object An Object contains the properties in the following table. - See:
Properties:
Name Type Description offcanvas.selector
string Document selector identifying the offcanvas element Returns:
- Type
- void
-
(static) toggle(offcanvas) : {Promise.<boolean>}
-
Toggles the offcanvas in or out of the viewport. This method simply delegates to the open or close methods as appropriate.
Parameters:
Name Type Description offcanvas
Object An Object contains the properties in the following table. - See:
Properties:
Name Type Argument Description offcanvas.autoDismiss
'focusLoss' | 'none' <optional>
close behavior, valid values are focusLoss and none. If autoDismiss is default(focusLoss) then any click outside the offcanvas will close it. offcanvas.content
string Document selector identifying the main content. offcanvas.displayMode
'push' | 'overlay' <optional>
how to show the offcanvas, valid values are push or overlay. Default: defined by theme. offcanvas.edge
'start' | 'end' | 'top' | 'bottom' <optional>
the edge of the offcanvas, valid values are start, end, top, bottom. This property is optional if the offcanvas element has a "oj-offcanvas-" + class specified. offcanvas.modality
'modal' | 'modeless' <optional>
The modality of the offcanvas. Valid values are modal and modeless. Default: modeless. If the offcanvas is modal, interaction with the main content area is disabled like in a modal dialog. offcanvas.selector
string Document selector identifying the offcanvas element. offcanvas.size
string <optional>
size width or height of the offcanvas: width if edge is start or end and height if edge is to and bottom. Default to the computed width or height of the offcanvas. Returns:
A promise that is resolved to boolean true when all transitions have completed
- Type
- Promise.<boolean>