1.0.8 • Published 2 years ago

pushstate-js v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

pushstate.js

pushstate.js adds a native way to listen for changes in the address bar, similar to how a pushstate event might work (if one existed). It works via an initializer function that sets up a MutationObserver, which fires an Event with the properties previous and current whenever the observer detects changes to the document's subtree or childList and the URL in the address bar (window.location.href) has also changed.

Installation

npm i pushstate-js

Usage

import intiailizePushstateEvent from 'pushstate-js';
intiailizePushstateEvent();

window.addEventListener('pushstate', ({ current, previous }) => {
  // do whatever you want with `current` and `previous`
});

It's that simple. Enjoy!

I'm happy to respond to and/or resolve any suggestions or bug reports, so feel free to open an issue.

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago