TrailPointer¶
Under Construction
This documentation is auto-generated, and is a work in progress. Please see the source code at https://github.com/phetsims/scenery/blob/main/js/util/TrailPointer.ts for the most up-to-date information.
Overview¶
Points to a specific node (with a trail), and whether it is conceptually before or after the node.
There are two orderings: - rendering order: the order that node selves would be rendered, matching the Trail implicit order - nesting order: the order in depth first with entering a node being "before" and exiting a node being "after"
TODO: more seamless handling of the orders. or just exclusively use the nesting order https://github.com/phetsims/scenery/issues/1581
@author Jonathan Olson <jonathan.olson@colorado.edu>
Class TrailPointer¶
Constructor¶
new TrailPointer( trail : Trail, isBefore : boolean )¶
Instance Methods¶
isActive() : this is ActiveTrailPointer¶
copy() : TrailPointer¶
setBefore( isBefore : boolean )¶
getRenderSwappedPointer() : TrailPointer | null¶
Return the equivalent pointer that swaps before and after (may return null if it doesn't exist)
getRenderBeforePointer() : TrailPointer | null¶
getRenderAfterPointer() : TrailPointer | null¶
compareRender( other : TrailPointer ) : number¶
In the render order, will return 0 if the pointers are equivalent, -1 if this pointer is before the other pointer, and 1 if this pointer is after the other pointer.
compareNested( other : TrailPointer ) : number¶
Like compareRender, but for the nested (depth-first) order
TODO: optimization? https://github.com/phetsims/scenery/issues/1581
equalsRender( other : TrailPointer ) : boolean¶
equalsNested( other : TrailPointer ) : boolean¶
hasTrail() : boolean¶
Will return false if this pointer has gone off of the beginning or end of the tree (will be marked with isAfter or isBefore though)
nestedForwards() : this | null¶
Moves this pointer forwards one step in the nested order
TODO: refactor with "Side"-like handling https://github.com/phetsims/scenery/issues/1581
nestedBackwards() : this | null¶
Moves this pointer backwards one step in the nested order
eachNodeBetween( other : TrailPointer, callback : ( node: Node ) => void )¶
Treats the pointer as render-ordered (includes the start pointer 'before' if applicable, excludes the end pointer 'before' if applicable
eachTrailBetween( other : TrailPointer, callback : TrailCallback )¶
Treats the pointer as render-ordered (includes the start pointer 'before' if applicable, excludes the end pointer 'before' if applicable
depthFirstUntil( other : TrailPointer, callback : ActiveTrailPointerCallback, excludeEndpoints : boolean )¶
Recursively (depth-first) iterates over all pointers between this pointer and 'other', calling callback( pointer ) for each pointer. If excludeEndpoints is truthy, the callback will not be called if pointer is equivalent to this pointer or 'other'.
If the callback returns a truthy value, the subtree for the current pointer will be skipped (applies only to before-pointers)
toString() : string¶
Returns a string form of this object
Instance Properties¶
trail : Trail | null¶
isBefore : boolean¶
isAfter : boolean¶
Static Methods¶
compareNested( trailA : Trail, isBeforeA : boolean, trailB : Trail, isBeforeB : boolean ) : number¶
Same as new TrailPointer( trailA, isBeforeA ).compareNested( new TrailPointer( trailB, isBeforeB ) )
eachTrailUnder( trail : Trail, callback : TrailCallback )¶
Calls callback( trail ) for this trail, and each descendant trail. If callback returns true, subtree will be skipped
eachPaintedTrailBetween( a : Trail, b : Trail, callback : ( trail: Trail ) => void, excludeEndTrails : boolean, rootNode : Node )¶
Like eachTrailBetween, but only fires for painted trails. If callback returns true, subtree will be skipped
eachTrailBetween( a : Trail, b : Trail, callback : ( trail: Trail ) => void, excludeEndTrails : boolean, rootNode : Node )¶
Global way of iterating across trails. when callback returns true, subtree will be skipped
Type ActiveTrailPointer¶
WithoutNull<TrailPointer, "trail">
Source Code¶
See the source for TrailPointer.ts in the scenery repository.