mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-07-30 09:43:05 -04:00
Implemented source file linkage through metadata
This commit is contained in:
@@ -107,13 +107,7 @@ function initialize(config) { // eslint-disable-line func-style
|
||||
|
||||
/* Component: sidebar with table of contents - register two separate
|
||||
listeners, as the offset at the top might change */
|
||||
new Material.Event.MatchMedia("(min-width: 960px) and (max-width: 1219px)",
|
||||
new Material.Event.Listener(window, [
|
||||
"scroll", "resize", "orientationchange"
|
||||
], new Material.Sidebar.Position(
|
||||
"[data-md-component=toc]",
|
||||
"[data-md-component=header]")))
|
||||
new Material.Event.MatchMedia("(min-width: 1220px)",
|
||||
new Material.Event.MatchMedia("(min-width: 960px)",
|
||||
new Material.Event.Listener(window, [
|
||||
"scroll", "resize", "orientationchange"
|
||||
], new Material.Sidebar.Position(
|
||||
|
||||
@@ -36,6 +36,7 @@ export default class Position {
|
||||
* @property {HTMLElement} header_ - Header
|
||||
* @property {number} height_ - Current sidebar height
|
||||
* @property {number} offset_ - Current page y-offset
|
||||
* @property {boolean} pad_ - Pad when header is fixed
|
||||
*
|
||||
* @param {(string|HTMLElement)} el - Selector or HTML element
|
||||
* @param {(string|HTMLElement)} header - Selector or HTML element
|
||||
@@ -58,8 +59,9 @@ export default class Position {
|
||||
throw new ReferenceError
|
||||
this.header_ = ref
|
||||
|
||||
/* Initialize current height */
|
||||
/* Initialize current height and test whether header is fixed */
|
||||
this.height_ = 0
|
||||
this.pad_ = window.getComputedStyle(this.header_).position === "fixed"
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +74,7 @@ export default class Position {
|
||||
}, 0)
|
||||
|
||||
/* Set lock offset for element with largest top offset */
|
||||
this.offset_ = top - this.header_.offsetHeight
|
||||
this.offset_ = top - (this.pad_ ? this.header_.offsetHeight : 0)
|
||||
this.update()
|
||||
}
|
||||
|
||||
@@ -98,7 +100,7 @@ export default class Position {
|
||||
/* Set bounds of sidebar container - must be calculated on every run, as
|
||||
the height of the content might change due to loading images etc. */
|
||||
const bounds = {
|
||||
top: this.header_.offsetHeight,
|
||||
top: this.pad_ ? this.header_.offsetHeight : 0,
|
||||
bottom: this.parent_.offsetTop + this.parent_.offsetHeight
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,10 @@ export default class GitHub extends Abstract {
|
||||
constructor(el) {
|
||||
super(el)
|
||||
|
||||
/* Adjust base URL to reach API endpoints */
|
||||
this.base_ = this.base_.replace("github.com/", "api.github.com/repos/")
|
||||
/* Adjust base URL to reach API endpoints and remove trailing slash */
|
||||
this.base_ = this.base_
|
||||
.replace("github.com/", "api.github.com/repos/")
|
||||
.replace(/\/$/, "")
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user