class sap.ui.core.routing.History

Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Extends:
Module: sap/ui/core/routing/History
Application Component: CA-UI5-COR

Constructor

Used to determine the sap.ui.core.routing.HistoryDirection of the current or a future navigation, done with a sap.ui.core.routing.Router or sap.ui.core.routing.HashChanger.

ATTENTION: this class will not be accurate if someone does hash-replacement without the named classes above. If you are manipulating the hash directly, this class is not supported anymore.

new sap.ui.core.routing.History(oHashChanger)
Param Type Default Value Description
oHashChanger sap.ui.core.routing.HashChanger

required, without a HashChanger this class cannot work. The class needs to be aware of the hash-changes.


Methods Overview

Method Description
getDirection

Determines what the navigation direction for a newly given hash would be It will say Unknown if there is a history foo - bar (current history) - foo If you now ask for the direction of the hash "foo" you get Unknown because it might be backwards or forwards. For hash replacements, the history stack will be replaced at this position for the history.

getHistoryStateOffset

Returns the length difference between the history state stored in browser's pushState and the state maintained in this class.

The function returns undefined when

  • The current state in browser's history pushState isn't initialized, for example, between a new hash is set or replaced and the "hashChange" event is processed by this class
  • History pushState is already used before UI5 History is initialized, and UI5 can't maintain the hash history by using the browser pushState

Once the "hashChange" event is processed by this class, this method always returns 0. However, before a "hashChange" event reaches this class, it returns the offset between the new hash and the previous one within the history state.

sap.ui.core.routing.History.getInstance
getPreviousHash

gets the previous hash in the history - if the last direction was Unknown or there was no navigation yet, undefined will be returned

getDirection

Determines what the navigation direction for a newly given hash would be It will say Unknown if there is a history foo - bar (current history) - foo If you now ask for the direction of the hash "foo" you get Unknown because it might be backwards or forwards. For hash replacements, the history stack will be replaced at this position for the history.

Param Type DefaultValue Description
sNewHash string

optional, if this parameter is not passed the last hashChange is taken.

getHistoryStateOffset

Returns the length difference between the history state stored in browser's pushState and the state maintained in this class.

The function returns undefined when

Once the "hashChange" event is processed by this class, this method always returns 0. However, before a "hashChange" event reaches this class, it returns the offset between the new hash and the previous one within the history state.

sap.ui.core.routing.History.getInstance

getPreviousHash

gets the previous hash in the history - if the last direction was Unknown or there was no navigation yet, undefined will be returned