Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johanholmerin/popstate-direction
Popstate direction events
https://github.com/johanholmerin/popstate-direction
Last synced: 2 months ago
JSON representation
Popstate direction events
- Host: GitHub
- URL: https://github.com/johanholmerin/popstate-direction
- Owner: johanholmerin
- License: mit
- Created: 2018-05-12T08:02:06.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-21T22:04:56.000Z (about 1 year ago)
- Last Synced: 2024-10-17T13:47:48.057Z (2 months ago)
- Language: JavaScript
- Size: 77.1 KB
- Stars: 16
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Popstate direction events
Emits `forward` and `back` events on popstate. Completely transparent,
preserves all History functionality and works with `location.hash`. Follows the
same semantics as popstate.## Installation
```sh
# Yarn
yarn add popstate-direction# npm
npm install popstate-direction
```## Usage
The library must be included before any call to `history.pushState` or
`history.replaceState`, before setting `location.hash`, or accessing
`history.state`.```javascript
import 'popstate-direction';window.addEventListener('forward', event => {
console.log(event, history.state);
});
window.addEventListener('back', event => {
console.log(event, history.state);
});
```## Compatibility
Written in ES6. If transpiled should work in all browsers that support the
History API.