This function of a JSAV instance initializes an empty linked list. Options that the optional parameter can specify:
horizontal vertical
. Possible horizontal values are “left”, “center”, “right” and vertical values “top”, “center”, “bottom”. Defaults to center center
. Only has an effect if relativeTo is
specified.center center
. Only
has an effect if relativeTo is specified.The returned list instance is controlled through a collection of methods explained next. In addition, the list has the common functions such as .id()
, .css(...)
, .show()
, and .hide()
.
Returns the first or last node in the list. If there are no nodes in the list, returns undefined.
Adds the given value
or node
as the first item in the list. Returns the list, so calls can be chained.
Adds the given value
or node
as the last item in the list. Returns the list, so calls can be chained.
Adds the given value
or node
to be the index
th item in the list. The first item in the list has index 0. Returns the list, so calls can be chained.
Returns the node at index
. First item has index 0. If no such index exists, returns undefined
.
Removes the first or last node in the list. Returns the removed node.
Removes the node at index
in the list. First item has index 0. Returns the removed node.
Returns the size of the list.
This function (re)calculates the layout for the list. Note, that the library does not do this automatically. That means that after changing the list, you should call this manually at the end of each animation step.
Options supported by the layout function:
updateLeft
If true, the horizontal position (that is, left) of the nodes are calculated.
Defaults to true.updateTop
If true, the vertical position (that is, top) of the nodes are calculated.
Defaults to true.If the call to layout is, for example, list.layout({updateLeft: false, updateTop: false}), only the edges
in the list are redrawn.
Returns a new node that can be added to the list.
Removes the DOM element of this structure from the document. This is useful, for example, in re-initializing exercises when the existing structure needs to be removed.
Adds the CSS class className
to the list and animates the changes.
Removes the CSS class className
from the list and animates the changes.
Toggles the CSS class className
of the list and animates the changes.
Return true/false based on if the list has the CSS class className
.
There are functions to attach event handlers for the nodes and edges in the list. The events that can be listened for are: click, dblclick, mousedown, mousemove, mouseup, mouseenter, and mouseleave. See the tree documentation for details.
A node in a list has the same functions as a tree node: .value([newValue])
, .highlight()/unhighlight()
, .show()/.hide()
, and .css(...)
. In addition, it has the following functions.
Returns the next node in the linked list. If no next, returns null.
Sets the next node to be the passed node
. The optional second argument options
should be an object. The following option(s) are supported:
edgeLabel
: specify a label shown on the edge connecting the node to the next.Returns the JSAV Edge object that points to the next item in the list.
Adds the CSS class className
to the node and animates the changes.
Removes the CSS class className
from the node and animates the changes.
Toggles the CSS class className
of the node and animates the changes.
Return true/false based on if the node has the CSS class className
.