aurelia-history-browser

  • Version 1.4.0
  • Published
  • 226 kB
  • 2 dependencies
  • MIT license

Install

npm i aurelia-history-browser
yarn add aurelia-history-browser
pnpm add aurelia-history-browser

Overview

An implementation of the Aurelia history interface based on standard browser hash change and push state mechanisms.

Index

Functions

function configure

configure: (config: Object) => void;
  • Configures the plugin by registering BrowserHistory as the implementation of History in the DI container.

    Parameter config

    The FrameworkConfiguration object provided by Aurelia.

Classes

class BrowserHistory

class BrowserHistory extends History {}
  • An implementation of the basic history API.

constructor

constructor(linkHandler: LinkHandler);
  • Creates an instance of BrowserHistory

    Parameter linkHandler

    An instance of LinkHandler.

method activate

activate: (options?: Object) => boolean;
  • Activates the history object.

    Parameter options

    The set of options to activate history with.

    Returns

    Whether or not activation occurred.

method deactivate

deactivate: () => void;
  • Deactivates the history object.

method getAbsoluteRoot

getAbsoluteRoot: () => string;
  • Returns the fully-qualified root of the current history object.

    Returns

    The absolute root of the application.

method getHistoryIndex

getHistoryIndex: () => number;
  • Returns the current index in the navigation history.

    Returns

    The current index.

method getState

getState: (key: string) => any;
  • Gets a key in the history page state.

    Parameter key

    The key for the value. The value for the key.

method go

go: (movement: number) => void;
  • Move to a specific position in the navigation history.

    Parameter movement

    The amount of steps, positive or negative, to move.

method navigate

navigate: (
fragment?: string,
{ trigger, replace }?: { trigger?: boolean; replace?: boolean }
) => boolean;
  • Causes a history navigation to occur.

    Parameter fragment

    The history fragment to navigate to.

    Parameter options

    The set of options that specify how the navigation should occur. Promise if triggering navigation, otherwise true/false indicating if navigation occurred.

method navigateBack

navigateBack: () => void;
  • Causes the history state to navigate back.

method setState

setState: (key: string, value: any) => void;
  • Sets a key in the history page state.

    Parameter key

    The key for the value.

    Parameter value

    The value to set.

method setTitle

setTitle: (title: string) => void;
  • Sets the document title.

class DefaultLinkHandler

class DefaultLinkHandler extends LinkHandler {}
  • The default LinkHandler implementation. Navigations are triggered by click events on anchor elements with relative hrefs when the history instance is using pushstate.

constructor

constructor();
  • Creates an instance of DefaultLinkHandler.

method activate

activate: (history: BrowserHistory) => void;
  • Activate the instance.

    Parameter history

    The BrowserHistory instance that navigations should be dispatched to.

method deactivate

deactivate: () => void;
  • Deactivate the instance. Event handlers and other resources should be cleaned up here.

method findClosestAnchor

static findClosestAnchor: (el: Element) => Element;
  • Finds the closest ancestor that's an anchor element.

    Parameter el

    The element to search upward from.

    Returns

    The link element that is the closest ancestor.

method getEventInfo

static getEventInfo: (event: Event) => AnchorEventInfo;
  • Gets the href and a "should handle" recommendation, given an Event.

    Parameter event

    The Event to inspect for target anchor and href.

method targetIsThisWindow

static targetIsThisWindow: (target: Element) => boolean;
  • Gets a value indicating whether or not an anchor targets the current window.

    Parameter target

    The anchor element whose target should be inspected.

    Returns

    True if the target of the link element is this window; false otherwise.

class LinkHandler

class LinkHandler {}
  • Class responsible for handling interactions that should trigger browser history navigations.

method activate

activate: (history: BrowserHistory) => void;
  • Activate the instance.

    Parameter history

    The BrowserHistory instance that navigations should be dispatched to.

method deactivate

deactivate: () => void;
  • Deactivate the instance. Event handlers and other resources should be cleaned up here.

Interfaces

interface AnchorEventInfo

interface AnchorEventInfo {}
  • Provides information about how to handle an anchor event.

property anchor

anchor: Element;
  • The anchor element or null if not-applicable.

property href

href: string;
  • The href of the link or null if not-applicable.

property shouldHandleEvent

shouldHandleEvent: boolean;
  • Indicates whether the event should be handled or not.

Package Files (1)

Dependencies (2)

Dev Dependencies (20)

Peer Dependencies (0)

No peer dependencies.

Badge

To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/aurelia-history-browser.

  • Markdown
    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/aurelia-history-browser)
  • HTML
    <a href="https://www.jsdocs.io/package/aurelia-history-browser"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>