Skip to content

Commit

Permalink
Keeping scroll position (if possible)
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Jul 10, 2020
1 parent 502512d commit b7d8caf
Show file tree
Hide file tree
Showing 7 changed files with 904 additions and 1,136 deletions.
7 changes: 5 additions & 2 deletions lib/dom-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author Jason Mulligan <jason.mulligan@avoidwork.com>
* @copyright 2020
* @license BSD-3-Clause
* @version 3.1.4
* @version 3.1.5
*/

"use strict";
Expand Down Expand Up @@ -61,6 +61,8 @@
if (!includes(this.routes, newHash)) {
this.route(this.routes.filter(i => includes(i, newHash))[0] || this.start);
} else {
const y = document.body.scrollTop;

render(() => {
try {
const oldHashes = oldHash ? oldHash.split(this.delimiter) : [],
Expand Down Expand Up @@ -91,6 +93,7 @@
trigger: newTrigger
});

document.body.scrollTop = y;
this.log(r);
this.callback(r);
} catch (err) {
Expand Down Expand Up @@ -192,7 +195,7 @@
return obj;
}

factory.version = "3.1.4";
factory.version = "3.1.5";

// CJS, AMD & window supported
if (typeof exports !== "undefined") {
Expand Down
6 changes: 3 additions & 3 deletions lib/dom-router.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b7d8caf

Please sign in to comment.