Flyout

new Flyout(options) → {Class}

Embeds an html flyout component to house off canvas content that overlays a container pain from either the right or the left.

Parameters:
NameTypeDescription
optionsobject

The options for the flyout.

Properties
NameTypeDescription
animationDelaynumber

Total runtime of close animation. must be synced with css.

closeButtonClassesstring

Classes for the close button.

closeButtonTitlestring

Text for the close button title.

closeOnOutsideClickboolean

Close the flyout on a click outside of it?

closeOnOutsideClickExceptionsArray

Array of selectors to ignore when checking for outside clicks.

contentstring

The html content.

expandableboolean

Whether the flyout shows an extra trigger to allow expanding to a larger width (set below).

expandableTitlestring

Title/a11y text for the expandable button.

expandableWidthnumber

Width to expand to if expandable is true.

descriptionstring

The optional description for the flyout.

desktopWidthnumber

Desktop width in percent.

directionstring

Direction to fly in from, left or right.

idstring

Id for the flyout.

insertPositionstring

Insert position relative to target.

lockBodyboolean

Whether to lock body scroll when open.

maxWidthnumber

Max width in pixels.

mobileBreakpointnumber

Mobile breakpoint.

mobileWidthnumber

Mobile width in percent.

onClosefunction

Function to fire when closed.

onOpenfunction

Function to fire when opened.

positionstring

Fixed or absolute positioning.

renderOnInitboolean

Render on initialization?

showDividerboolean

Show the divider below optional title?

simplebarboolean

Enable the simple bar ui for the body content scroll?

targetstring

The selector to append the flyout to.

titlestring

The optional title for the flyout.

triggersstring

The selector[s] of the trigger that shows it.

wrapperClassesstring

Additional classes for the wrapper.

zIndexnumber

Z-index for the flyout.

Since
  • 1.0.5
Returns:

The class instance.

Type: 
Class
Example
import Flyout from '@gravityforms/components/html/admin/modules/Flyout';

function Example() {
     const flyoutInstance = new Flyout( {
         id: 'example-flyout',
         renderOnInit: false,
         target: '#example-target',
         targetPosition: 'beforeend',
         theme: 'cosmos',
     } );

     // Some time later we can render it. This is only done if we set renderOnInit to false.
     // If true it will render on initialization.
     flyoutInstance.init();
}

Members

(static) closeFlyout

Closes the flyout and fires the onClose function that can be passed in. Can be used by external developers by firing the method on the instance. Also closes all instances if the event 'gform/flyout/close-all' is fired on the document.

Since
  • 1.0.5

(static) handleExpandable

Handles expanding the flyout on a trigger click if the option is enabled.

Since
  • 1.0.5

(static) handleKeyEvents

Handles accessibility focus looping on the flyout using the focusLoop util.

Since
  • 1.0.5

(static) handleResize

Handle window resize events for the flyout

Since
  • 1.0.5

(static) handleTriggerClick

Handles opening/closing the flyout on a trigger click.

Since
  • 1.0.5

(static) maybeCloseFlyout

Closes all instances except the one that gets passed the activeId when the event 'gform/flyout/close' is fired on the document.

Since
  • 1.0.5

Methods

(static) bindEvents() → {void}

Bind events to the component.

Since
  • 1.0.5
Returns:
Type: 
void

(static) expandFlyout() → {void}

Expands the flyout to the defined expandableWidth while removing the max-width setting.

Since
  • 1.0.5
Returns:
Type: 
void

(static) flyoutTemplate(options) → {string}

The template function that returns html for the flyout. Options below are passed from constructor and described there.

Parameters:
NameTypeDescription
optionsobject

The options for the flyout.

Properties
NameTypeDescription
closeButtonClassesstring

The classes for the close button.

closeButtonTitlestring

The title for the close button.

contentstring

The content for the flyout.

descriptionstring

The description for the flyout. Found under the title in the header.

desktopWidthnumber

The flyout desktop width in percentage.

directionstring

Direction to fly in from, left or right.

expandableboolean

Whether the flyout shows an extra trigger to allow expanding to a larger width.

expandableTitlestring

The title for the expandable trigger.

idstring

The id for the flyout.

maxWidthnumber

The flyout max width in pixels.

mobileBreakpointnumber

The breakpoint for mobile in pixels.

mobileWidthnumber

The flyout mobile width in percentage.

positionstring

The position of the flyout, fixed or absolute positioning

showDividerboolean

Whether to show the divider between the header and content.

simplebarboolean

Whether to use simplebar for the content.

titlestring

The title for the flyout.

wrapperClassesstring

The classes for the wrapper.

zIndexnumber

The z-index for the flyout.

Since
  • 1.0.5
Returns:
Type: 
string
Example
import { flyoutTemplate } from '@gravityforms/components/html/admin/modules/Flyout';

function Example() {
     const flyoutTemplateHTML = flyoutTemplateTemplate( options );
     document.body.insertAdjacentHTML( 'beforeend', flyoutTemplateHTML );
}

(static) init() → {void}

Initialize the component.

Since
  • 1.0.5
Returns:
Type: 
void

(static) render() → {void}

Renders the component into the dom.

Since
  • 1.0.5
Returns:
Type: 
void

(static) showFlyout() → {void}

Opens the flyout and fires the onOpen function that can be passed in.

Since
  • 1.0.5
Returns:
Type: 
void

(static) shrinkFlyout() → {void}

Returns the flyout to its natural width. The complexity comes from handling a mix of max-width (which doesn't animate) and % widths for responsive.

Since
  • 1.0.5
Returns:
Type: 
void

(static) storeElements() → {void}

Stores useful HTMLElements on the instance in the elements namespace after render.

Since
  • 1.0.5
Returns:
Type: 
void

(static) updateFlyoutWidth() → {void}

Hides the expander button if the flyout fills its available space.

Since
  • 1.0.5
Returns:
Type: 
void