mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Added back scroll locking
This commit is contained in:
parent
de49689f99
commit
ece3253d4f
Binary file not shown.
Before Width: | Height: | Size: 150 KiB |
Binary file not shown.
Before Width: | Height: | Size: 150 KiB |
@ -6,6 +6,15 @@ template: overrides/main.html
|
||||
|
||||
## Material for MkDocs
|
||||
|
||||
### 7.0.0 <small>_ February 22, 2021</small>
|
||||
|
||||
- Added support for deploying multiple versions
|
||||
- Added support for adding a language selector
|
||||
- Added support for rendering admonitions as inline blocks
|
||||
- Rewrite of the underlying reactive architecture
|
||||
- Removed Webpack in favor of reactive build strategy (-480 dependencies)
|
||||
- Fixed keyboard navigation for code blocks after content tabs switch
|
||||
|
||||
### 6.2.8 <small>_ February 4, 2021</small>
|
||||
|
||||
- Updated Japanese and Polish translations
|
||||
|
@ -234,28 +234,53 @@ Admonitions and [Details][11] can also be rendered as inline blocks (i.e.
|
||||
sidebars), moving them to the right using the `inline` + `end` modifiers, or
|
||||
to the left using only the `inline` modifier.
|
||||
|
||||
_Example_:
|
||||
=== "inline end"
|
||||
|
||||
_Example_ / _Result_:
|
||||
|
||||
!!! info inline end
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et
|
||||
euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo
|
||||
purus auctor massa, nec semper lorem quam in massa.
|
||||
|
||||
``` markdown
|
||||
!!! info inline end
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
|
||||
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
|
||||
massa, nec semper lorem quam in massa.
|
||||
Lorem ipsum dolor sit amet, consectetur
|
||||
adipiscing elit. Nulla et euismod nulla.
|
||||
Curabitur feugiat, tortor non consequat
|
||||
finibus, justo purus auctor massa, nec
|
||||
semper lorem quam in massa.
|
||||
```
|
||||
|
||||
_Result_:
|
||||
|
||||
=== "inline end"
|
||||
|
||||
[![Admonition, inline end][13]][13]
|
||||
Use `inline end` to align to the right (left for rtl languages).
|
||||
|
||||
=== "inline"
|
||||
|
||||
[![Admonition, inline][14]][14]
|
||||
_Example_ / _Result_:
|
||||
|
||||
!!! info inline
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et
|
||||
euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo
|
||||
purus auctor massa, nec semper lorem quam in massa.
|
||||
|
||||
``` markdown
|
||||
!!! info inline
|
||||
Lorem ipsum dolor sit amet, consectetur
|
||||
adipiscing elit. Nulla et euismod nulla.
|
||||
Curabitur feugiat, tortor non consequat
|
||||
finibus, justo purus auctor massa, nec
|
||||
semper lorem quam in massa.
|
||||
```
|
||||
|
||||
Use `inline` to align to the left (right for rtl languages).
|
||||
|
||||
_If there's insufficient space to render the admonition next to the block, the
|
||||
admonition will stretch to the full width of the viewport, e.g. on mobile
|
||||
viewports._
|
||||
|
||||
[12]: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/stylesheets/main/_modifiers.scss
|
||||
[13]: ../assets/screenshots/admonition-inline-end.png
|
||||
[14]: ../assets/screenshots/admonition-inline.png
|
||||
|
||||
### Supported types
|
||||
|
||||
@ -363,8 +388,8 @@ the default type, and thus fallback for unknown type qualifiers, is `note`:
|
||||
### Custom admonitions
|
||||
|
||||
If you want to add a custom admonition type, all you need is a color and an
|
||||
`svg` icon. Copy the icon's `svg` code from the [`.icons`][15] folder and add the
|
||||
following CSS to an [additional stylesheet][16]:
|
||||
`svg` icon. Copy the icon's `svg` code from the [`.icons`][13] folder and add the
|
||||
following CSS to an [additional stylesheet][14]:
|
||||
|
||||
``` css
|
||||
:root {
|
||||
@ -388,7 +413,7 @@ following CSS to an [additional stylesheet][16]:
|
||||
|
||||
You should now be able to create an admonition of the `pied-piper` type. Note
|
||||
that you can also use this technique to override existing admonition icons or
|
||||
colors. [You can even add animations][17].
|
||||
colors. [You can even add animations][15].
|
||||
|
||||
<style>
|
||||
:root {
|
||||
@ -427,6 +452,6 @@ _Result_:
|
||||
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
|
||||
massa, nec semper lorem quam in massa.
|
||||
|
||||
[15]: https://github.com/squidfunk/mkdocs-material/tree/master/material/.icons
|
||||
[16]: ../customization.md#additional-css
|
||||
[17]: https://facelessuser.github.io/pymdown-extensions/extensions/details/
|
||||
[13]: https://github.com/squidfunk/mkdocs-material/tree/master/material/.icons
|
||||
[14]: ../customization.md#additional-css
|
||||
[15]: https://facelessuser.github.io/pymdown-extensions/extensions/details/
|
||||
|
@ -43,7 +43,7 @@ _Result_:
|
||||
|
||||
[2]: #attribute-list
|
||||
[3]: ../setup/changing-the-colors.md#primary-color
|
||||
[4]: javascript:app.dialog$.next("Done!")
|
||||
[4]: javascript:alert$.next("Done!")
|
||||
|
||||
### Adding primary buttons
|
||||
|
||||
|
@ -123,7 +123,7 @@ loading][6] via [additional JavaScript][2]:
|
||||
=== "docs/javascripts/tables.js"
|
||||
|
||||
``` js
|
||||
app.document$.subscribe(function() {
|
||||
document$.subscribe(function() {
|
||||
var tables = document.querySelectorAll("article table")
|
||||
tables.forEach(function(table) {
|
||||
new Tablesort(table)
|
||||
|
@ -90,8 +90,8 @@ as [documented here][2]._
|
||||
:octicons-beaker-24: Experimental
|
||||
|
||||
If your documentation is available in multiple languages, a _language selector_
|
||||
can be added to the header next to the search bar. Languages can be defined via
|
||||
`mkdocs.yml`:
|
||||
can be added to the header next to the search bar. Alternate languages can be
|
||||
defined via `mkdocs.yml`:
|
||||
|
||||
``` yaml
|
||||
extra:
|
||||
|
@ -408,7 +408,7 @@ JavaScript][33], you can subscribe to the `keyboard$` observable and attach
|
||||
your custom event listener:
|
||||
|
||||
``` js
|
||||
app.keyboard$.subscribe(function(key) {
|
||||
keyboard$.subscribe(function(key) {
|
||||
if (key.mode === "global" && key.type === "x") {
|
||||
/* Add custom keyboard handler here */
|
||||
key.claim()
|
||||
|
@ -68,7 +68,7 @@ which will emit the current `URL` to listen for navigation events and register
|
||||
a page view event with:
|
||||
|
||||
``` js
|
||||
app.location$.subscribe(function(url) {
|
||||
location$.subscribe(function(url) {
|
||||
/* Add custom page event tracking here */
|
||||
})
|
||||
```
|
||||
|
@ -316,8 +316,9 @@ customize the `transform` function, you can do this by [overriding the
|
||||
|
||||
``` html
|
||||
{% block config %}
|
||||
{{ super() }}
|
||||
<script>
|
||||
var search = {
|
||||
var __search = {
|
||||
transform: function(query) {
|
||||
return query
|
||||
}
|
||||
@ -345,8 +346,9 @@ directory and [override the `config` block][21]:
|
||||
|
||||
``` html
|
||||
{% block config %}
|
||||
{{ super() }}
|
||||
<script>
|
||||
var search = {
|
||||
var __search = {
|
||||
worker: "<url>"
|
||||
}
|
||||
</script>
|
||||
|
File diff suppressed because one or more lines are too long
7
material/assets/javascripts/bundle.b83fae36.min.js.map
Normal file
7
material/assets/javascripts/bundle.b83fae36.min.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -217,7 +217,7 @@
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<script src="{{ 'assets/javascripts/bundle.d663aa10.min.js' | url }}"></script>
|
||||
<script src="{{ 'assets/javascripts/bundle.b83fae36.min.js' | url }}"></script>
|
||||
{% for path in config["extra_javascript"] %}
|
||||
<script src="{{ path | url }}"></script>
|
||||
{% endfor %}
|
||||
|
@ -64,7 +64,8 @@ import {
|
||||
} from "./integrations"
|
||||
import {
|
||||
patchIndeterminate,
|
||||
patchScrollfix
|
||||
patchScrollfix,
|
||||
patchScrolllock
|
||||
} from "./patches"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
@ -128,6 +129,7 @@ keyboard$
|
||||
/* Set up patches */
|
||||
patchIndeterminate({ document$ })
|
||||
patchScrollfix({ document$ })
|
||||
patchScrolllock({ viewport$, tablet$ })
|
||||
|
||||
/* Set up header and main area observable */
|
||||
const header$ = watchHeader(getComponentElement("header"), { viewport$ })
|
||||
@ -208,4 +210,5 @@ window.viewport$ = viewport$ /* Viewport observable */
|
||||
window.tablet$ = tablet$ /* Tablet observable */
|
||||
window.screen$ = screen$ /* Screen observable */
|
||||
window.print$ = print$ /* Print mode observable */
|
||||
window.alert$ = alert$ /* Alert subject */
|
||||
window.component$ = component$ /* Component observable */
|
||||
|
@ -22,3 +22,4 @@
|
||||
|
||||
export * from "./indeterminate"
|
||||
export * from "./scrollfix"
|
||||
export * from "./scrolllock"
|
||||
|
86
src/assets/javascripts/patches/scrolllock/index.ts
Normal file
86
src/assets/javascripts/patches/scrolllock/index.ts
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2021 Martin Donath <martin.donath@squidfunk.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import {
|
||||
Observable,
|
||||
animationFrameScheduler,
|
||||
combineLatest,
|
||||
of
|
||||
} from "rxjs"
|
||||
import {
|
||||
delay,
|
||||
map,
|
||||
observeOn,
|
||||
switchMap,
|
||||
withLatestFrom
|
||||
} from "rxjs/operators"
|
||||
|
||||
import { resetScrollLock, setScrollLock } from "~/actions"
|
||||
import { Viewport, watchToggle } from "~/browser"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Helper types
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Patch options
|
||||
*/
|
||||
interface PatchOptions {
|
||||
viewport$: Observable<Viewport> /* Viewport observable */
|
||||
tablet$: Observable<boolean> /* Tablet breakpoint observable */
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Functions
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Patch the document body to lock when search is open
|
||||
*
|
||||
* For mobile and tablet viewports, the search is rendered full screen, which
|
||||
* leads to scroll leaking when at the top or bottom of the search result. This
|
||||
* function locks the body when the search is in full screen mode, and restores
|
||||
* the scroll position when leaving.
|
||||
*
|
||||
* @param options - Options
|
||||
*/
|
||||
export function patchScrolllock(
|
||||
{ viewport$, tablet$ }: PatchOptions
|
||||
): void {
|
||||
combineLatest([watchToggle("search"), tablet$])
|
||||
.pipe(
|
||||
map(([active, tablet]) => active && !tablet),
|
||||
switchMap(active => of(active)
|
||||
.pipe(
|
||||
delay(active ? 400 : 100),
|
||||
observeOn(animationFrameScheduler)
|
||||
)
|
||||
),
|
||||
withLatestFrom(viewport$)
|
||||
)
|
||||
.subscribe(([active, { offset: { y }}]) => {
|
||||
if (active)
|
||||
setScrollLock(document.body, y)
|
||||
else
|
||||
resetScrollLock(document.body)
|
||||
})
|
||||
}
|
1
typings/_/index.d.ts
vendored
1
typings/_/index.d.ts
vendored
@ -70,6 +70,7 @@ declare global {
|
||||
tablet$: Observable<boolean> /* Tablet breakpoint observable */
|
||||
screen$: Observable<boolean> /* Screen breakpoint observable */
|
||||
print$: Observable<void> /* Print mode observable */
|
||||
alert$: Subject<string> /* Alert subject */
|
||||
component$: Observable<Component> /* Component observable */
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user