summaryrefslogtreecommitdiff
path: root/client/js/router.js
diff options
context:
space:
mode:
authorrr- <rr-@sakuya.pl>2016-07-08 00:46:48 +0200
committerrr- <rr-@sakuya.pl>2016-07-08 00:54:24 +0200
commit5d8dd9cb05f084177a102b1197d8b6f4a247ad58 (patch)
tree189c29010e5130a0d73068ad63601969c7fc53a5 /client/js/router.js
parent8901658c1718b600f6583801a1158ff16632600c (diff)
client/paging: fix endless scroll return path
Since some refactors it has always been returning to page 1.
Diffstat (limited to 'client/js/router.js')
-rw-r--r--client/js/router.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/client/js/router.js b/client/js/router.js
index cfe405f..2226059 100644
--- a/client/js/router.js
+++ b/client/js/router.js
@@ -6,6 +6,8 @@
// - simplified method chains
// - added ability to call .save() in .exit() without side effects
// - page refresh recovers state from history
+// - rename .save() to .replaceState()
+// - offer .url
const pathToRegexp = require('path-to-regexp');
const clickEvent = document.ontouchstart ? 'touchstart' : 'click';
@@ -47,7 +49,7 @@ class Context {
history.pushState(this.state, this.title, this.canonicalPath);
}
- save() {
+ replaceState() {
history.replaceState(this.state, this.title, this.canonicalPath);
}
};
@@ -149,10 +151,10 @@ class Router {
var ctx = new Context(path, state);
if (dispatch) {
this.dispatch(ctx, () => {
- ctx.save();
+ ctx.replaceState();
});
} else {
- ctx.save();
+ ctx.replaceState();
}
return ctx;
}
@@ -184,6 +186,10 @@ class Router {
router.stop();
location.href = ctx.canonicalPath;
}
+
+ get url() {
+ return location.pathname + location.search + location.hash;
+ }
};
const _onPopState = router => {