listen to hash changes
This commit is contained in:
@@ -2,6 +2,8 @@ const history = require('sheet-router/history')
|
|||||||
const sheetRouter = require('sheet-router')
|
const sheetRouter = require('sheet-router')
|
||||||
const document = require('global/document')
|
const document = require('global/document')
|
||||||
const href = require('sheet-router/href')
|
const href = require('sheet-router/href')
|
||||||
|
const hash = require('sheet-router/hash')
|
||||||
|
const hashMatch = require('hash-match')
|
||||||
const sendAction = require('send-action')
|
const sendAction = require('send-action')
|
||||||
const mutate = require('xtend/mutable')
|
const mutate = require('xtend/mutable')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
@@ -205,6 +207,13 @@ function appInit (opts) {
|
|||||||
// enable HTML5 history API
|
// enable HTML5 history API
|
||||||
if (opts.href !== false) pushLocationSub(href)
|
if (opts.href !== false) pushLocationSub(href)
|
||||||
if (opts.history !== false) pushLocationSub(history)
|
if (opts.history !== false) pushLocationSub(history)
|
||||||
|
if (opts.hash !== false) {
|
||||||
|
pushLocationSub(function (navigate) {
|
||||||
|
hash(function (fragment) {
|
||||||
|
navigate(hashMatch(fragment))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -20,8 +20,9 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"global": "^4.3.0",
|
"global": "^4.3.0",
|
||||||
|
"hash-match": "^1.0.2",
|
||||||
"send-action": "^1.1.0",
|
"send-action": "^1.1.0",
|
||||||
"sheet-router": "^3.0.0",
|
"sheet-router": "^3.1.0",
|
||||||
"xhr": "^2.2.0",
|
"xhr": "^2.2.0",
|
||||||
"xtend": "^4.0.1",
|
"xtend": "^4.0.1",
|
||||||
"yo-yo": "^1.2.0"
|
"yo-yo": "^1.2.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user