Constructor
new Page(pagesArea, pageTemplate, blank, hooks, options)
Creates an instance of Page.
Creates an instance of Page.
Parameters:
Name | Type | Description |
---|---|---|
pagesArea |
HTMLElement | The container element for all pages. |
pageTemplate |
HTMLTemplateElement | Template for creating new pages. |
blank |
boolean | Indicates if this is a blank page. |
hooks |
Object | Hook functions for custom behavior. |
options |
Object | Additional layout or rendering options. |
- Source:
Methods
addListeners(contents) → {boolean}
Adds event listeners for scroll and resize to monitor overflows.
Adds event listeners for scroll and resize to monitor overflows.
Parameters:
Name | Type | Description |
---|---|---|
contents |
DocumentFragment | The content being rendered (used in resize checks). |
- Source:
Returns:
True if listeners were added.
- Type
- boolean
addResizeObserver(contents)
Adds a ResizeObserver to monitor wrapper size changes.
Adds a ResizeObserver to monitor wrapper size changes.
Parameters:
Name | Type | Description |
---|---|---|
contents |
DocumentFragment | The contents being observed for overflow changes. |
- Source:
(async) append(contents, breakToken) → {Promise.<Object>}
Appends content to the existing layout using the current layout method.
Appends content to the existing layout using the current layout method.
Parameters:
Name | Type | Description |
---|---|---|
contents |
DocumentFragment | The contents to append. |
breakToken |
Object | The token to continue rendering from. |
- Source:
Returns:
A new breakToken after rendering.
- Type
- Promise.<Object>
checkOverflowAfterResize(contents)
Checks if the page content has overflowed after a resize.
Checks if the page content has overflowed after a resize.
Parameters:
Name | Type | Description |
---|---|---|
contents |
DocumentFragment | The content being checked. |
- Source:
checkUnderflowAfterResize(contents)
Checks if the page content has underflowed (e.g., content was removed).
Checks if the page content has underflowed (e.g., content was removed).
Parameters:
Name | Type | Description |
---|---|---|
contents |
DocumentFragment | The content being checked. |
- Source:
clear()
Clears the wrapper and listeners, resetting the layout state.
Clears the wrapper and listeners, resetting the layout state.
- Source:
create(template, afteropt) → {HTMLElement}
Creates a new page element from the template and inserts it into the DOM.
Creates a new page element from the template and inserts it into the DOM.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
template |
HTMLTemplateElement | The template to use for page creation. |
|
after |
HTMLElement |
<optional> |
Optional reference element to insert after. |
- Source:
Returns:
The newly created page element.
- Type
- HTMLElement
createWrapper() → {HTMLElement}
Creates a wrapper element inside the page's content area.
Creates a wrapper element inside the page's content area.
- Source:
Returns:
The wrapper element.
- Type
- HTMLElement
destroy()
Cleans up the page, removing all DOM elements and listeners.
Cleans up the page, removing all DOM elements and listeners.
- Source:
getByParent(ref, entries) → {HTMLElement|undefined}
Finds a DOM element by its data-ref
attribute in a list of elements.
Finds a DOM element by its data-ref
attribute in a list of elements.
Parameters:
Name | Type | Description |
---|---|---|
ref |
string | The reference string to look for. |
entries |
Array.<HTMLElement> | A list of elements to search. |
- Source:
Returns:
The matching element, if found.
- Type
- HTMLElement | undefined
index(pgnum)
Sets the page index and updates relevant attributes and classes.
Sets the page index and updates relevant attributes and classes.
Parameters:
Name | Type | Description |
---|---|---|
pgnum |
number | The page index number (0-based). |
- Source:
(async) layout(contents, breakToken, prevPageopt) → {Promise.<(Object|undefined)>}
Performs layout rendering of content within the page.
Performs layout rendering of content within the page.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
contents |
DocumentFragment | The contents to render. |
|
breakToken |
Object | The token where content rendering should resume. |
|
prevPage |
Page |
<optional> |
The previous page, used for continuity. |
- Source:
Returns:
A new breakToken if content overflowed, or undefined.
- Type
- Promise.<(Object|undefined)>
onOverflow(func)
Registers a callback to run when content overflows the page.
Registers a callback to run when content overflows the page.
Parameters:
Name | Type | Description |
---|---|---|
func |
function | The overflow callback function. |
- Source:
onUnderflow(func)
Registers a callback to run when content underflows the page.
Registers a callback to run when content underflows the page.
Parameters:
Name | Type | Description |
---|---|---|
func |
function | The underflow callback function. |
- Source:
removeListeners()
Removes event listeners related to overflow and resizing.
Removes event listeners related to overflow and resizing.
- Source: