Documentation

This commit is contained in:
squidfunk 2019-11-20 15:37:04 +01:00
parent 89214b1897
commit b711d15dac
4 changed files with 27 additions and 26 deletions

View File

@ -58,35 +58,35 @@ interface WatchOptions {
/**
* Set anchor blur
*
* @param anchor - Anchor HTML element
* @param el - Anchor element
* @param blur - Anchor blur
*/
export function setAnchorBlur(
anchor: HTMLAnchorElement, blur: boolean
el: HTMLAnchorElement, blur: boolean
): void {
anchor.setAttribute("data-md-state", blur ? "blur" : "")
el.setAttribute("data-md-state", blur ? "blur" : "")
}
/**
* Set sidebar state lock
* Set anchor active
*
* @param anchor - Anchor HTML element
* @param el - Anchor element
* @param active - Whether the anchor is active
*/
export function setAnchorActive(
anchor: HTMLAnchorElement, active: boolean
el: HTMLAnchorElement, active: boolean
): void {
anchor.classList.toggle("md-nav__link--active", active)
el.classList.toggle("md-nav__link--active", active)
}
/**
* Reset anchor
*
* @param anchor - Anchor HTML element
* @param el - Anchor element
*/
export function resetAnchor(anchor: HTMLAnchorElement) {
anchor.removeAttribute("data-md-state")
anchor.classList.remove("md-nav__link--active")
export function resetAnchor(el: HTMLAnchorElement) {
el.removeAttribute("data-md-state")
el.classList.remove("md-nav__link--active")
}
/* ------------------------------------------------------------------------- */

View File

@ -42,22 +42,22 @@ export interface Header {
/**
* Set header shadow
*
* @param header - Header HTML element
* @param el - Header element
* @param shadow - Shadow
*/
export function setHeaderShadow(
header: HTMLElement, shadow: boolean
el: HTMLElement, shadow: boolean
): void {
header.setAttribute("data-md-state", shadow ? "shadow" : "")
el.setAttribute("data-md-state", shadow ? "shadow" : "")
}
/**
* Reset header
*
* @param header - Header HTML element
* @param el - Header element
*/
export function resetHeader(header: HTMLElement): void {
header.removeAttribute("data-md-state")
export function resetHeader(el: HTMLElement): void {
el.removeAttribute("data-md-state")
}
/* ------------------------------------------------------------------------- */

View File

@ -41,13 +41,14 @@ export type NavigationIndex = Map<HTMLInputElement, HTMLElement>
/**
* Set navigation overflow scrolling
*
* @param nav - Navigation element
* @param el - Navigation element
* @param active - Whether overflow scrolling is active
*/
export function setNavigationOverflowScrolling(
nav: HTMLElement, active: boolean
el: HTMLElement, active: boolean
): void {
nav.style.webkitOverflowScrolling = active ? "touch" : ""
el.style.background = active ? "yellow" : "" // TODO: hack, temporary
el.style.webkitOverflowScrolling = active ? "touch" : ""
}
/* ------------------------------------------------------------------------- */
@ -55,14 +56,14 @@ export function setNavigationOverflowScrolling(
/**
* Create an observable to index all navigation elements
*
* @param nav - Top-level navigation element
* @param el - Top-level navigation element
*
* @return Navigation index observable
*/
export function watchNavigationIndex(
nav: HTMLElement
el: HTMLElement
): Observable<NavigationIndex> {
const list = getElements("nav", nav)
const list = getElements("nav", el)
/* Build index to map inputs to navigation lists */
const index = new Map<HTMLInputElement, HTMLElement>()

View File

@ -58,7 +58,7 @@ interface WatchOptions {
/**
* Set sidebar height
*
* @param el - Sidebar HTML element
* @param el - Sidebar element
* @param height - Sidebar height
*/
export function setSidebarHeight(
@ -70,7 +70,7 @@ export function setSidebarHeight(
/**
* Set sidebar lock
*
* @param el - Sidebar HTML element
* @param el - Sidebar element
* @param lock - Whether the sidebar is locked
*/
export function setSidebarLock(
@ -82,7 +82,7 @@ export function setSidebarLock(
/**
* Reset sidebar
*
* @param el - Sidebar HTML element
* @param el - Sidebar element
*/
export function resetSidebar(el: HTMLElement): void {
el.removeAttribute("data-md-state")