Utils for setting, storing, and restoring scroll position
Properties:
Name | Type | Description |
---|---|---|
stack |
array | Undo stack of scroll positions |
fwdstack |
array | Redo stack of scroll positions |
lastID |
object | Object containing { loc: {number}, title: {string} } |
initted |
boolean | Flag set after initialization |
Requires
Methods
backwards()
Restore position backward in stack (undo)
fetchHTML() → {string}
Get the HTML contents of the TOC
Returns:
HTML contents of the TOC
- Type
- string
forwards()
Restore position forward in stack
idProximity(backopt) → {object}
Get proximity to nearest element with ID
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
back |
boolean |
<optional> |
false | Flag to force moving backward (up) in document |
Returns:
Object with {loc: {x,y}, title: {string}}
- Type
- object
init() → {array}
Initialize scroll stack and store current position
Returns:
[x offset, y offset]
- Type
- array
move(position)
Move the table of contents into doc for printing
Parameters:
Name | Type | Description |
---|---|---|
position |
number | string | If position is "top" or 0, clone the TOC to top or location of TOC tag in document |
push() → {array}
Push current position to stack in memory
Returns:
[x offset, y offset]
- Type
- array
restore(force) → {array}
Restore last position
Parameters:
Name | Type | Description |
---|---|---|
force |
boolean | Force restore |
Returns:
[x position, y position]
- Type
- array
restoreProximity()
Restore scroll position to nearest saved proximity
saveProximity()
Save proximity to nearest element with ID
store() → {array}
Store current position to Cocoa object
Returns:
[x offset, y offset]
- Type
- array