Edit this page

API Layers
module up.layer

Unpoly allows you to open page fragments in an overlay. Overlays may be stacked infinitely.

A variety of overlay modes are supported, such as modal dialogs, popup overlays or drawers. You may customize their appearance and behavior.

Layers are isolated, meaning a screen in one layer will not accidentally see elements or events from another layer. For instance, fragment links will only update elements from the current layer unless you explicitly target another layer.

Overlays allow you to break up a complex screen into subinteractions. Subinteractions take place in overlays and may span one or many pages while the original screen remains open in the background. Once the subinteraction is done, the overlay is closed and a result value is communicated back to the parent layer.


Guides

Features

Essentials

All features

HTML
[up-accept] stable

Accepts the current layer when the link is clicked.

HTML
[up-close] deprecated

When this element is clicked, closes a currently open overlay.

HTML
[up-dismiss] stable

Dismisses the current layer when the link is clicked.

HTML
[up-drawer] deprecated

Clicking this link will load the destination via AJAX and open the given selector in a modal drawer that slides in from the edge of the screen.

JS
up.layer.accept([value], [options]) stable

Accepts the current layer.

JS
up:layer:accept stable

This event is emitted before a layer is accepted.

JS
up:layer:accepted stable

This event is emitted after a layer was accepted.

JS
up.layer.affix(element, selector, attrs) experimental

Creates an element with the given selector and appends it to the current layer's outmost element.

JS
up.layer.ask(options) stable

Opens an overlay and returns a promise for its acceptance.

JS
up.layer.config stable

Configures default attributes for new overlays.

JS
up.layer.contains(element) stable

Returns whether the given element is contained by the current layer.

JS
up.layer.context experimental

The context of the current layer.

JS
up.layer.count stable

Returns the number of layers in the layer stack.

JS
up.layer.current stable

Returns the current layer in the layer stack.

JS
up.layer.dismiss([value], [options]) stable

Dismisses the current layer.

JS
up:layer:dismiss stable

This event is emitted before a layer is dismissed.

JS
up:layer:dismissed stable

This event is emitted after a layer was dismissed.

JS
up.layer.dismissOverlays([value], [options]) stable

Dismisses all overlays.

JS
up.layer.element stable

The outmost element of the current layer.

JS
up.layer.element stable

The outmost element of the current layer.

JS
up.layer.emit(eventType, [props]) stable

Emits an event on the current layer's element.

JS
up.layer.front stable

Returns the frontmost layer in the layer stack.

JS
up.layer.get([value]) stable

Returns an up.Layer object for the given element or layer option.

JS
up.layer.getAll([layer]) experimental

Returns an array of up.Layer objects matching the given layer option.

JS
up.layer.history stable

Whether fragment updates within the current layer can affect browser history and window title.

JS
up.layer.isFront() stable

Returns whether the current layer is the frontmost layer.

JS
up.layer.isOverlay() stable

Returns whether the current layer is not the root layer.

JS
up.layer.isRoot() stable

Returns whether the current layer is the root layer.

JS
up.layer.location stable

The location URL of the current layer.

JS
up:layer:location:changed experimental

This event is emitted after a layer's location property has changed value.

JS
up.layer.mode stable

The current layer's mode which governs its appearance and behavior.

HTML
[up-layer=new] stable

Follows this link and opens the result in a new overlay.

JS
up.layer.off(events, [selector], listener) stable

Unbinds an event listener previously bound to the current layer.

JS
up.layer.on(types, [selector], [options], listener) stable

Listens to a DOM event that originated on an element contained by the current layer.

JS
up.layer.open([options]) stable

Opens a new overlay.

JS
up:layer:open stable

This event is emitted before an overlay is opened.

JS
up:layer:opened stable

This event is emitted after a new overlay was placed into the DOM.

JS
up.layer.overlays stable

Returns an array of all overlays.

JS
up.layer.parent stable

Returns the parent layer of the current layer.

JS
up.layer.root stable

Returns the root layer.

JS
up.layer.size stable

The size of the current layer.

JS
up.layer.stack stable

A list of layers that are currently open.

HTML
[up-modal] deprecated

Clicking this link will load the destination via AJAX and open the given selector in a modal overlay.

JS
up.modal.close(options) deprecated

Closes a currently open overlay.

JS
up.modal.config deprecated

Sets default options for future modal overlays.

JS
up.modal.contains(elementOrSelector) deprecated

Returns whether the given element or selector is contained within the current layer.

JS
up.modal.coveredUrl() deprecated

Returns the location URL of the layer behind the current overlay.

JS
up.modal.extract(selector, document, options) deprecated

Extracts the given CSS selector from the given HTML string and opens the results in a modal overlay.

JS
up.modal.follow(linkOrSelector, [options]) deprecated

Opens the given link's destination in a modal overlay.

JS
up.modal.isOpen() deprecated

Returns whether an overlay is currently open.

JS
up.modal.url() deprecated

Returns the location URL of the fragment displayed in the current overlay.

JS
up.modal.visit(url, options) deprecated

Opens a modal overlay for the given URL.

HTML
[up-popup] deprecated

Clicking this link will load the destination via AJAX and open the given selector in a popup overlay.

JS
up.popup.attach(anchor, [options]) deprecated

Attaches a popup overlay to the given element or selector.

JS
up.popup.close(options) deprecated

Closes a currently open overlay.

JS
up.popup.config deprecated

Sets default options for future popup overlays.

JS
up.popup.contains(elementOrSelector) deprecated

Returns whether the given element or selector is contained within the current layer.

JS
up.popup.coveredUrl() deprecated

Returns the location URL of the layer behind the current overlay.

JS
up.popup.isOpen() deprecated

Returns whether an overlay is currently open.

JS
up.popup.url() deprecated

Returns the location URL of the fragment displayed in the current overlay.