@devinle/radar

1.0.9 • Public • Published

Radar

A window history no config router.

npm NPM GitHub last commit

Install

npm install @devinle/radar

// In your script
import { radar } from '@devinle/radar';

// Make a callback function
const callback = (data) => { console.log(data); };

// Data Signature within callback is as follows
data = {
  from: 'from/page/url,
  to: 'to/page/url'
};

// Register a callback with the radar-change event
// This event will receive data
radar.on('radar-change', callback);

// Remove a specific callback from the radar-change
radar.off('radar-change', callback);

Usage

All links delegate to the body and will make a request to the window pushState.

<a href="/url/here">A Link</a>

Prevent History Request

To avoid calling the window pushState function, apply the radar-ignore class to a link.

<a href="/url/here" class="radar-ignore">A Link</a>

Method radar.go(evt)

The body is bound to the radar.go method and all links clicked within the body will call this API method unless it contains the ignore class.

Tests

yarn run test

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @devinle/radar

Weekly Downloads

0

Version

1.0.9

License

MIT

Unpacked Size

198 kB

Total Files

8

Last publish

Collaborators

  • devinle