motion-router

0.3.6 • Public • Published

MotionRouter

A simple client-side router with support for old browsers (Inspired on AngularJS Router and Laravel Router).

Note: The router use hash.

Installation

  • Using bower:

    $ bower install motion-router
  • Using npm:

    $ npm install motion-router

Usage

// New router instance
var router = new MotionRouter();

// Routes
router
  .when('/', function() {
    console.log('Home');
  })
  .when('/one', callback);

// Prefix for routes
router.prefix('/group')
  .when('/one', callback) // #/group/one
  .when('/two', callback); // #/group/two

// Not registered route
router
  .otherwise(function() {
    router.redirect('/'); // Redirection to home
  });

// Run =D
router.run();

Run example

$ npm run example

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.3.60latest

Version History

VersionDownloads (Last 7 Days)Published
0.3.60
0.3.50
0.3.40
0.3.30
0.3.20
0.3.10
0.3.00
0.2.10
0.2.00
0.1.10
0.1.00

Package Sidebar

Install

npm i motion-router

Weekly Downloads

0

Version

0.3.6

License

MIT

Last publish

Collaborators

  • aeroxmotion