Revert "Improve jsdoc for tableOfContents.js and sectionObserver.js"
This mostly reverts commit f5ad6fe78a
but
keeps the SectionObserverProps typedef.
Instead, we will use @module introduced in
Ib68de8cd97cc1111a5a33e100e688d6832fc7e6e.
Change-Id: I7aff49a3d922889cc99bc4313a6cb416410a7a0d
This commit is contained in:
parent
8b5ea941e5
commit
27939ac6c9
|
@ -15,7 +15,6 @@
|
|||
* handler should be throttled.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-returns
|
||||
/**
|
||||
* Observe intersection changes with the viewport for one or more elements. This
|
||||
* is intended to be used with the headings in the content so that the
|
||||
|
@ -33,8 +32,8 @@
|
|||
* observed tags off the main thread and in a manner that does not cause
|
||||
* expensive forced synchronous layouts.
|
||||
*
|
||||
* @namespace SectionObserver
|
||||
* @param {SectionObserverProps} props
|
||||
* @return {SectionObserver}
|
||||
*/
|
||||
module.exports = function sectionObserver( props ) {
|
||||
props = Object.assign( {
|
||||
|
@ -128,9 +127,6 @@ module.exports = function sectionObserver( props ) {
|
|||
|
||||
/**
|
||||
* Pauses intersection observation until `resume` is called.
|
||||
*
|
||||
* @memberof SectionObserver
|
||||
* @instance
|
||||
*/
|
||||
function pause() {
|
||||
unbindScrollListener();
|
||||
|
@ -140,9 +136,6 @@ module.exports = function sectionObserver( props ) {
|
|||
|
||||
/**
|
||||
* Resumes intersection observation.
|
||||
*
|
||||
* @memberof SectionObserver
|
||||
* @instance
|
||||
*/
|
||||
function resume() {
|
||||
bindScrollListener();
|
||||
|
@ -151,9 +144,6 @@ module.exports = function sectionObserver( props ) {
|
|||
/**
|
||||
* Cleans up event listeners and intersection observer. Should be called when
|
||||
* the observer is permanently no longer needed.
|
||||
*
|
||||
* @memberof SectionObserver
|
||||
* @instance
|
||||
*/
|
||||
function unmount() {
|
||||
unbindScrollListener();
|
||||
|
@ -164,8 +154,6 @@ module.exports = function sectionObserver( props ) {
|
|||
* Set a list of HTML elements to observe for intersection changes.
|
||||
*
|
||||
* @param {NodeList} list
|
||||
* @memberof SectionObserver
|
||||
* @instance
|
||||
*/
|
||||
function setElements( list ) {
|
||||
props.elements = list;
|
||||
|
@ -175,6 +163,13 @@ module.exports = function sectionObserver( props ) {
|
|||
// Calculate intersection on page load.
|
||||
calcIntersection();
|
||||
|
||||
/**
|
||||
* @typedef {Object} SectionObserver
|
||||
* @property {pause} pause
|
||||
* @property {resume} resume
|
||||
* @property {unmount} unmount
|
||||
* @property {setElements} setElements
|
||||
*/
|
||||
return {
|
||||
pause,
|
||||
resume,
|
||||
|
|
|
@ -22,12 +22,11 @@ const TOGGLE_CLASS = 'sidebar-toc-toggle';
|
|||
* @property {onToggleClick} onToggleClick Called when a list item is clicked.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-returns
|
||||
/**
|
||||
* Initializes the sidebar's Table of Contents.
|
||||
*
|
||||
* @namespace TableOfContents
|
||||
* @param {TableOfContentsProps} props
|
||||
* @return {TableOfContents}
|
||||
*/
|
||||
module.exports = function tableOfContents( props ) {
|
||||
let /** @type {HTMLElement | undefined} */ activeTopSection;
|
||||
|
@ -108,8 +107,6 @@ module.exports = function tableOfContents( props ) {
|
|||
* to a top level heading in the ToC.
|
||||
*
|
||||
* @param {string} id
|
||||
* @memberof TableOfContents
|
||||
* @instance
|
||||
*/
|
||||
function expandSection( id ) {
|
||||
const tocSection = document.getElementById( id );
|
||||
|
@ -136,9 +133,8 @@ module.exports = function tableOfContents( props ) {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} id
|
||||
* @memberof TableOfContents
|
||||
* @instance
|
||||
*/
|
||||
function changeActiveSection( id ) {
|
||||
|
||||
|
@ -180,8 +176,6 @@ module.exports = function tableOfContents( props ) {
|
|||
|
||||
/**
|
||||
* @param {string} id
|
||||
* @memberof TableOfContents
|
||||
* @instance
|
||||
*/
|
||||
function toggleExpandSection( id ) {
|
||||
const expandedSectionIds = getExpandedSectionIds();
|
||||
|
@ -233,6 +227,16 @@ module.exports = function tableOfContents( props ) {
|
|||
|
||||
initialize();
|
||||
|
||||
/**
|
||||
* @typedef {Object} TableOfContents
|
||||
* @property {changeActiveSection} changeActiveSection
|
||||
* @property {expandSection} expandSection
|
||||
* @property {toggleExpandSection} toggleExpandSection
|
||||
* @property {string} ACTIVE_SECTION_CLASS
|
||||
* @property {string} EXPANDED_SECTION_CLASS
|
||||
* @property {string} LINK_CLASS
|
||||
* @property {string} TOGGLE_CLASS
|
||||
*/
|
||||
return {
|
||||
expandSection,
|
||||
changeActiveSection,
|
||||
|
|
Loading…
Reference in New Issue