Skip to content

Commit 6f46451

Browse files
author
Konstantin Lubinets
committed
При добавлении новых данных в "Моей линии" всегда кидало в топ страницы, а потом скроллит вниз
1 parent 9d5cb87 commit 6f46451

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const storage = [];
2+
const prevPathname = document.location.pathname;
23

34
const scrollTo = ($el, top, left) => {
45
if($el) {
@@ -41,7 +42,9 @@ module.exports = ({ history, elementId, reset = true, limit = 20 }) => {
4142
const { location } = history;
4243
const state = location.state || {};
4344
const { resetScroll, resetOnAction = 'PUSH'} = state;
44-
let position = [0, 0];
45+
if (window.location.pathname !== prevPathname) {
46+
let position = [0, 0];
47+
}
4548

4649
switch (history.action) {
4750
case 'POP':
@@ -59,6 +62,7 @@ module.exports = ({ history, elementId, reset = true, limit = 20 }) => {
5962

6063
break;
6164
}
65+
prevPathname = location.pathname;
6266
}
6367
}
6468
};

0 commit comments

Comments
 (0)