Skip to content

Commit a1b590d

Browse files
authored
make ability not to scroll in some cases
1 parent 1e75bbb commit a1b590d

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/main.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,28 @@ module.exports = ({ history, elementId, reset = true, limit = 20 }) => {
2626
}
2727
},
2828
render: () => {
29-
const { location } = history;
30-
const state = location.state || {};
31-
const { resetScroll, resetOnAction = 'PUSH'} = state;
32-
let position = [0, 0];
29+
if(ctx.get('scroll') !== false) {
30+
const { location } = history;
31+
const state = location.state || {};
32+
const { resetScroll, resetOnAction = 'PUSH'} = state;
33+
let position = [0, 0];
3334

34-
switch (history.action) {
35-
case 'POP':
36-
if(storage.length && !(resetScroll && resetOnAction === 'POP')) {
37-
position = storage.pop();
38-
}
39-
40-
$el && $el.scrollTo(...position);
35+
switch (history.action) {
36+
case 'POP':
37+
if(storage.length && !(resetScroll && resetOnAction === 'POP')) {
38+
position = storage.pop();
39+
}
4140

42-
break;
43-
case 'PUSH':
44-
if(reset || (resetScroll && resetOnAction === 'PUSH')) {
4541
$el && $el.scrollTo(...position);
46-
}
4742

48-
break;
43+
break;
44+
case 'PUSH':
45+
if(reset || (resetScroll && resetOnAction === 'PUSH')) {
46+
$el && $el.scrollTo(...position);
47+
}
48+
49+
break;
50+
}
4951
}
5052
}
5153
};

0 commit comments

Comments
 (0)