🌐 AI搜索 & 代理 主页
Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added alwaysScrollHeader option
  • Loading branch information
naneko authored Jan 9, 2023
commit d9ebafd49b7d714eadaf85cff1f7a92e0471f13b
13 changes: 13 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ window.$docsify = {
};
```

## alwaysScrollHeader

- Type: `Boolean`
- Default: `false`

Always scrolls to ID/header when specified in route. By default, page will use browser's scroll auto-restoration.

```js
window.$docsify = {
alwaysScrollHeader: true,
};
```

## autoHeader

- Type: `Boolean`
Expand Down
1 change: 1 addition & 0 deletions src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default function (vm) {
const config = merge(
{
auto2top: false,
alwaysScrollHeader: false,
autoHeader: false,
basePath: '',
catchPluginErrors: true,
Expand Down
6 changes: 3 additions & 3 deletions src/core/event/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { scrollIntoView, scroll2Top } from './scroll';
export function Events(Base) {
return class Events extends Base {
$resetEvents(source) {
const { auto2top } = this.config;
const { auto2top, alwaysScrollHeader } = this.config;

(() => {
// Rely on the browser's scroll auto-restoration when going back or forward
// If alwaysScrollHeader is false (default), rely on the browser's scroll auto-restoration when going back or forward
if (source === 'history') {
return;
alwaysScrollHeader && scrollIntoView(this.route.path, this.route.query.id);
}
// Scroll to ID if specified
if (this.route.query.id) {
Expand Down