Home Reference Source
public class | source

Pjax

Pjax.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public
public

Indicate if there is an animation in progress.

Method Summary

Public Methods
public

Return the currentURL cleaned.

public

Return a transition object.

public

getTransitionName(el: HTMLElement): String | undefined

Get transition name from HTMLElement attribute (data-transition).

public

goTo(url: String, transitionName: String)

Change the URL with push state and trigger the state change.

public

preventCheck(evt: MouseEvent, element: HTMLElement): Boolean

Determine if the link should be followed.

Private Methods
private

Attach event listeners.

private

boot()

Init the events.

private

Force the browser to go to a certain url.

private

getHref(el: HTMLElement): String | undefined

Get the .href parameter out of a link element

private

Load an url, will start an ajax request or load from the cache.

private

onLinkClick(evt: MouseEvent)

Callback called from click event.

private

Function called as soon the new page is ready.

private

onStateChange(transitionName: undefined, isAjax: boolean): boolean

Method called after a 'popstate' or from .goTo().

private

Function called as soon the transition is finished.

Inherited Summary

From class AbstractService
public
public
public

checkDependencies(dependencies: *[])

public

getService(serviceName: *): *

public

hasService(serviceName: *): *

public

init()

From class AbstractBootableService
public

boot()

Public Constructors

public constructor() source

Override:

AbstractService#constructor

Public Members

public currentState: * source

public linkHash: * source

public transitionProgress: Boolean source

Indicate if there is an animation in progress.

Public Methods

public getCurrentUrl(): String source

Return the currentURL cleaned.

Return:

String

currentUrl

public getTransition(prev: object, current: object): AbstractTransition source

Return a transition object.

Params:

NameTypeAttributeDescription
prev object

historyManager

current object

historyManager

Return:

AbstractTransition

Transition object

public getTransitionName(el: HTMLElement): String | undefined source

Get transition name from HTMLElement attribute (data-transition).

Params:

NameTypeAttributeDescription
el HTMLElement

Return:

String | undefined

The transition name

public goTo(url: String, transitionName: String) source

Change the URL with push state and trigger the state change.

Params:

NameTypeAttributeDescription
url String
transitionName String

public preventCheck(evt: MouseEvent, element: HTMLElement): Boolean source

Determine if the link should be followed.

Params:

NameTypeAttributeDescription
evt MouseEvent
element HTMLElement

Return:

Boolean

Private Methods

private bindEvents() source

Attach event listeners.

private boot() source

Init the events.

Override:

AbstractBootableService#boot

private forceGoTo(url: String) source

Force the browser to go to a certain url.

Params:

NameTypeAttributeDescription
url String

private getHref(el: HTMLElement): String | undefined source

Get the .href parameter out of a link element

Params:

NameTypeAttributeDescription
el HTMLElement

Return:

String | undefined

href

private load(url: String): Promise source

Load an url, will start an ajax request or load from the cache.

Params:

NameTypeAttributeDescription
url String

Return:

Promise

private onLinkClick(evt: MouseEvent) source

Callback called from click event.

Params:

NameTypeAttributeDescription
evt MouseEvent

private onNewPageLoaded(page: AbstractPage) source

Function called as soon the new page is ready.

Params:

NameTypeAttributeDescription
page AbstractPage

private onStateChange(transitionName: undefined, isAjax: boolean): boolean source

Method called after a 'popstate' or from .goTo().

Params:

NameTypeAttributeDescription
transitionName undefined
  • optional
  • default: undefined
isAjax boolean
  • optional
  • default: false

Return:

boolean

private onTransitionEnd() source

Function called as soon the transition is finished.