turbodombuilder - v0.9.22
    Preparing search index...

    Class TurboSelector<Type>

    TurboSelector

    Selector class that wraps an object and augments it with useful functions to manipulate it. It also proxies the object, so you can access properties and methods on the underlying object directly through the selector.

    Type Parameters

    • Type extends object = Node

      The type of the object it wraps.

    Hierarchy

    Index

    Constructors

    Properties

    boundListeners: Set<ListenerEntry>

    Readonly set of listeners bound to this node.

    bypassManagerOn: (e: Event) => boolean | TurboEventManagerStateProperties

    If you want the element to bypass the event manager and allow native events to seep through (in case you are preventing default events), you can set this field to a predicate that defines when to bypass the manager according to the passed event.

    childHandler: ChildHandler

    The child handler object associated with the node. It is the node itself (if it is handling its children) or its shadow root (if defined). Set it to change the node where the children are added/ removed/queried from when manipulating the node's children.

    childNodesArray: Node[]

    Static array of all the child nodes of the node.

    childrenArray: Element[]

    Static array of all the child elements of the node.

    siblingNodes: Node[]

    Static array of all the sibling nodes (including the node itself) of the node.

    siblings: Element[]

    Static array of all the sibling elements (including the element itself, if it is one) of the node.

    reifects: Set<StatefulReifect<any, object>>

    Readonly shallow set of the reifects attached to this object.

    onTransitionStart: Delegate<() => void>
    onTransitionEnd: Delegate<() => void>
    showTransition: StatefulReifect<Shown>

    The transition used by the element's show() and isShown methods. Directly modifying its value will modify all elements' default showTransition. Unless this is the desired outcome, set it to a new custom StatefulReifect.

    isShown: boolean

    Boolean indicating whether the element is shown or not, based on its showTransition.

    closestRoot: StylesRoot

    The closest root to the element in the document (the closest ShadowRoot, or the document's head).

    substrates: string[]

    Array of all the substrates attached to this element.

    currentSubstrate: string

    The current active substrate in the element.

    onSubstrateChange: Delegate<(prev: string, next: string) => void>

    A delegate fired every time the current substrate changes.

    element: Type

    The underlying, wrapped object.

    Methods

    • Parameters

      • Optionalclasses: string | string[]

        String of classes separated by spaces, or array of strings.

      Returns this

      Itself, allowing for method chaining.

      Add one or more CSS classes to the element.

    • Parameters

      • Optionalclasses: string | string[]

        String of classes separated by spaces, or array of strings.

      Returns this

      Itself, allowing for method chaining.

      Remove one or more CSS classes from the element.

    • Parameters

      • Optionalclasses: string | string[]

        String of classes separated by spaces, or array of strings.

      • Optionalforce: boolean

        (Optional) Boolean that turns the toggle into a one way-only operation. If set to false, then the class will only be removed, but not added. If set to true, then token will only be added, but not removed.

      Returns this

      Itself, allowing for method chaining.

      Toggle one or more CSS classes in the element.

    • Parameters

      • Optionalclasses: string | string[]

        String of classes separated by spaces, or array of strings.

      Returns boolean

      A boolean indicating whether the provided classes are included.

      Check if the element's class list contains the provided class(es).

    • Function

      setProperties

      Type Parameters

      • Tag extends
            | "symbol"
            | "animate"
            | "animateMotion"
            | "animateTransform"
            | "circle"
            | "clipPath"
            | "defs"
            | "desc"
            | "ellipse"
            | "feBlend"
            | "feColorMatrix"
            | "feComponentTransfer"
            | "feComposite"
            | "feConvolveMatrix"
            | "feDiffuseLighting"
            | "feDisplacementMap"
            | "feDistantLight"
            | "feDropShadow"
            | "feFlood"
            | "feFuncA"
            | "feFuncB"
            | "feFuncG"
            | "feFuncR"
            | "feGaussianBlur"
            | "feImage"
            | "feMerge"
            | "feMergeNode"
            | "feMorphology"
            | "feOffset"
            | "fePointLight"
            | "feSpecularLighting"
            | "feSpotLight"
            | "feTile"
            | "feTurbulence"
            | "filter"
            | "foreignObject"
            | "g"
            | "image"
            | "line"
            | "linearGradient"
            | "marker"
            | "mask"
            | "metadata"
            | "mpath"
            | "path"
            | "pattern"
            | "polygon"
            | "polyline"
            | "radialGradient"
            | "rect"
            | "set"
            | "stop"
            | "svg"
            | "switch"
            | "text"
            | "textPath"
            | "tspan"
            | "use"
            | "view"
            | (keyof HTMLElementTagNameMap)
            | (keyof MathMLElementTagNameMap)
            | (keyof TurboElementTagNameMap)

        The HTML tag of the element (for accurate autocompletion of available properties).

      Parameters

      • properties: TurboProperties<Tag>

        The properties object.

      • OptionalsetOnlyBaseProperties: boolean

        If set to true, will only set the base turbo properties (classes, text, style, id, children, parent, etc.) and ignore all other properties not explicitly defined in TurboProperties.

      Returns this

      Itself, allowing for method chaining.

      Sets the declared properties to the element (if possible).

    • Function

      setMvc

      Parameters

      Returns Mvc

      • The created or retrieved Mvc object.

      Sets MVC properties for a certain object. If no mvc field exists on the object, a new Mvc object will be created with the given properties.

    • Returns this

      Itself, allowing for method chaining.

      Destroys the element by removing it from the document and removing all its bound listeners.

    • Parameters

      • name: string

        The name of the attribute.

      • Optionalvalue: string | number | boolean

        The value of the attribute. Can be left blank to represent a true boolean.

      Returns this

      Itself, allowing for method chaining.

      Sets the value of an attribute on the element.

    • Parameters

      • name: string

        The name of the attribute to remove.

      Returns this

      Itself, allowing for method chaining.

      Removes an attribute from the element.

    • Returns this

      Itself, allowing for method chaining.

      Causes the element to lose focus.

    • Returns this

      Itself, allowing for method chaining.

      Sets focus on the element.

    • Function

      on

      Type Parameters

      • Type extends Node

        The type of the element.

      Parameters

      • type: string

        The type of the event.

      • listener: (e: Event, el: Type) => any

        The function that receives a notification.

      • Optionaloptions: AddEventListenerOptions

        An options object that specifies characteristics about the event listener.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns this

      Itself, allowing for method chaining.

      Adds an event listener to the element.

    • Function

      onTool

      Type Parameters

      • Type extends Node

        The type of the element.

      Parameters

      • type: string

        The type of the event.

      • toolName: string

        The name of the tool. Set to null or undefined to check for listeners not bound to a tool.

      • listener: (e: Event, el: Type) => any

        The function that receives a notification.

      • Optionaloptions: AddEventListenerOptions

        An options object that specifies characteristics about the event listener.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns this

      Itself, allowing for method chaining.

      Adds an event listener to the element.

    • Function

      executeAction

      Parameters

      • type: string

        The type of the event.

      • toolName: string

        The name of the tool. Set to null or undefined to fire listeners not bound to a tool.

      • event: Event

        The event to pass as parameter to the listeners.

      • Optionaloptions: AddEventListenerOptions

        Options object that specifies characteristics about the event listeners to fire.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns boolean

      Execute the listeners bound on this element for the given type and toolName. Simulates firing a type event on the element with toolName active.

    • Function

      hasListener

      Parameters

      • type: string

        The type of the event. Set to null or undefined to get all event types.

      • listener: (e: Event, el: this) => any

        The function that receives a notification.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns boolean

      • Whether the element has the given listener.

      Checks if the given event listener is bound to the element (in its boundListeners list).

    • Function

      hasToolListener

      Parameters

      • type: string

        The type of the event. Set to null or undefined to get all event types.

      • toolName: string

        The name of the tool the listener is attached to. Set to null or undefined to check for listeners not bound to a tool.

      • listener: (e: Event, el: this) => any

        The function that receives a notification.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns boolean

      • Whether the element has the given listener.

      Checks if the given event listener is bound to the element (in its boundListeners list).

    • Function

      hasListenersByType

      Parameters

      • type: string

        The type of the event. Set to null or undefined to get all event types.

      • OptionaltoolName: string

        The name of the tool to consider (if any). Set to null or undefined to check for listeners not bound to a tool.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns boolean

      • Whether the element has a listener of this type.

      Checks if the element has bound listeners of the given type (in its boundListeners list).

    • Function

      removeListener

      Parameters

      • type: string

        The type of the event.

      • listener: (e: Event, el: this) => any

        The function that receives a notification.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns this

      Itself, allowing for method chaining.

      Removes an event listener that is bound to the element (in its boundListeners list).

    • Function

      removeToolListener

      Parameters

      • type: string

        The type of the event.

      • toolName: string

        The name of the tool the listener is attached to. Set to null or undefined to check for listeners not bound to a tool.

      • listener: (e: Event, el: this) => any

        The function that receives a notification.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns this

      Itself, allowing for method chaining.

      Removes an event listener that is bound to the element (in its boundListeners list).

    • Function

      removeListenersByType

      Parameters

      • type: string

        The type of the event. Set to null or undefined to consider all types.

      • OptionaltoolName: string

        The name of the tool associated (if any). Set to null or undefined to check for listeners not bound to a tool.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns this

      Itself, allowing for method chaining.

      Removes all event listeners bound to the element (in its boundListeners list) assigned to the specified type.

    • Function

      removeAllListeners

      Parameters

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns this

      Itself, allowing for method chaining.

      Removes all event listeners bound to the element (in its boundListeners list).

    • Parameters

      Returns this

      Prevent default browser behavior on the provided event types. By default, all basic input events will be processed.

    • Function

      bringToFront

      Returns this

      Itself for chaining.

      Brings the element to the front amongst its siblings in the DOM.

    • Function

      sendToBack

      Returns this

      Itself for chaining.

      Sends the element to the back amongst its siblings in the DOM.

    • Function

      remove

      Returns this

      Itself, allowing for method chaining.

      Removes the node from the document.

    • Function

      addToParent

      Parameters

      • parent: Node

        The parent node to attach the element to.

      • Optionalindex: number

        The position at which to add the element relative to the parent's child list. Leave undefined to add the element at the end.

      • OptionalreferenceList: Node[] | NodeListOf<Node>

        The child list to use as computation reference for index placement. Defaults to the parent's childrenArray.

      Returns this

      Itself, allowing for method chaining.

      Add the element to the given parent node

    • Function

      addChild

      Parameters

      • Optionalchildren: Node | Node[]

        Array of (or single) child nodes.

      • Optionalindex: number

        The position at which to add the child relative to the parent's child list. Leave undefined to add the child at the end.

      • OptionalreferenceList: Node[] | NodeListOf<Node>

        The child list to use as computation reference for index placement. Defaults to the node's childrenArray.

      Returns this

      Itself, allowing for method chaining.

      Add one or more children to the element.

    • Function

      remChild

      Parameters

      • Optionalchildren: Node | Node[]

        Array of (or single) child nodes.

      Returns this

      Itself, allowing for method chaining.

      Remove one or more children from the element.

    • Function

      addChildBefore

      Parameters

      • Optionalchildren: Node | Node[]

        Array of (or single) child nodes to insert before sibling.

      • Optionalsibling: Node

        The sibling node to insert the children before.

      Returns this

      Itself, allowing for method chaining.

      Add one or more children to the element before the provided sibling. If the sibling is not found in the parent's children, the nodes will be added to the end of the parent's child list.

    • Function

      removeChildAt

      Parameters

      • Optionalindex: number

        The index of the child(ren) to remove.

      • Optionalcount: number

        The number of children to remove.

      • OptionalreferenceList: Node[] | NodeListOf<Node>

        The child list to use as computation reference for index placement and count. Defaults to the node's childrenArray.

      Returns this

      Itself, allowing for method chaining.

      Remove one or more child nodes from the element.

    • Function

      removeAllChildren

      Parameters

      • OptionalreferenceList: Node[] | NodeListOf<Node>

        The child list to representing all the nodes to remove. Defaults to the node's childrenArray.

      Returns this

      Itself, allowing for method chaining.

      Remove all children of the node.

    • Function

      childAt

      Parameters

      • Optionalindex: number

        The index of the child to retrieve.

      • OptionalreferenceList: Node[] | NodeListOf<Node>

        The child list to use as computation reference for index placement. Defaults to the node's childrenArray.

      Returns Node

      The child at the given index, or null if the index is invalid.

      Returns the child of the parent node at the given index. Any number inputted (including negatives) will be reduced modulo length of the list size.

    • Function

      indexOfChild

      Parameters

      • Optionalchild: Node

        The child element to find.

      • OptionalreferenceList: Node[] | NodeListOf<Node>

        The child list to use as computation reference for index placement. Defaults to the node's childrenArray.

      Returns number

      The index of the child node in the provided list, or -1 if the child is not found.

      Returns the index of the given child.

    • Function

      hasChild

      Parameters

      • Optionalchildren: Node | Node[]

        Array of (or single) child nodes.

      Returns boolean

      A boolean indicating whether the provided nodes belong to the parent or not.

      Identify whether one or more children belong to this parent node.

    • Function

      findInSubTree

      Parameters

      • Optionalchildren: Node | Node[]

        The child or children to check.

      Returns boolean

      True if the children belong to the node, false otherwise.

      Finds whether one or more children belong to this node.

    • Function

      findInParents

      Parameters

      • Optionalparents: Node | Node[]

        The parent(s) to check.

      Returns boolean

      True if the node is within the given parents, false otherwise.

      Finds whether this node is within the given parent(s).

    • Function

      indexInParent

      Parameters

      • OptionalreferenceList: Node[]

        The siblings list to use as computation reference for index placement. Defaults to the node's siblings.

      Returns number

      True if the children belong to the node, false otherwise.

      Finds whether one or more children belong to this node.

    • Function

      closest

      Parameters

      • type: string

        The (valid) CSS selector string. constructor/class to match.

      Returns Element

      The matching ancestor element, or null if no match is found.

      Finds the closest ancestor of the current element (or the current element itself) that matches the provided CSS selector.

    • Function

      closest

      Type Parameters

      • Type extends Element

        The type of element to find.

      Parameters

      • type: new (...args: any[]) => Type

        The class to match. constructor/class to match.

      Returns Type

      The matching ancestor element, or null if no match is found.

      Finds the closest ancestor of the current element (or the current element itself) that is an instance of the given class.

    • Parameters

      • callback: (el: this) => void

        The function to execute, with 1 parameter representing the instance itself.

      Returns this

      Itself, allowing for method chaining.

      Execute a callback on the node while still benefiting from chaining.

    • Function

      applyDefaults

      Parameters

      Returns this

      The same selector instance for chaining.

      Apply default properties to the underlying object, with optional smart merging for array-like keys. By default, merging will happen on all MVC properties that accept arrays (like controllers, handlers, tools, etc.) to allow for concatenation of such MVC pieces.

      const properties = {...};
      turbo(properties).applyDefaults({
      tag: "my-el",
      view: MyElementView,
      tools: [selectTool, panTool],
      controllers: KeyboardController
      });
    • Parameters

      Returns this

      Itself, allowing for method chaining.

      Show or hide the element (based on CSS) by transitioning in/out of the element's showTransition.

    • Function

      attachReifect

      Parameters

      Returns this

      • Itself, allowing for method chaining.

      Attach one or more reifects to the object.

    • Function

      detachReifect

      Parameters

      Returns this

      • Itself, allowing for method chaining.

      Detach one or more reifects from the object.

    • Function

      initializeReifect

      Type Parameters

      • State extends string | number | symbol

        The type of the reifect's states.

      Parameters

      • Optionalreifect: StatefulReifect<State>

        The reifect to initialize.

      • Optionalstate: State

        The state to initialize to (if the reifect is not stateless).

      • Optionaloptions: ReifectAppliedOptions<State>

        Optional overrides for the default values. Set to null to not set anything on the object.

      Returns this

      • Itself, allowing for method chaining.

      Initializes the reifect at the given state for the corresponding object.

    • Function

      applyReifect

      Type Parameters

      • State extends string | number | symbol

        The type of the reifect's states.

      Parameters

      • reifect: StatefulReifect<State>

        The reifect to apply.

      • Optionalstate: State

        The state to initialize to (if the reifect is not stateless).

      • Optionaloptions: ReifectAppliedOptions<State>

        Optional overrides for the default values. Set to null to not set anything on the object.

      Returns this

      • Itself, allowing for method chaining.

      Applies the reifect at the given state for the corresponding object.

    • Function

      toggleReifect

      Type Parameters

      • State extends string | number | symbol

        The type of the reifect's states.

      Parameters

      Returns this

      • Itself, allowing for method chaining.

      Toggles the reifect to the next state for the corresponding object.

    • Function

      reloadReifects

      Returns this

      • Itself, allowing for method chaining.

      Reloads all reifects attached to this object. Doesn't recompute values.

    • Function

      reloadTransitions

      Returns this

      • Itself, allowing for method chaining.

      Reloads all transitions attached to this object. Doesn't recompute values.

    • Function

      reifectEnabledState

      Parameters

      Returns ReifectEnabledObject

      • The enabled state.

      Get the reifect enabled state of this object. If a reifect is provided, the enabled state of the object for this specific reifect will be returned. otherwise, the global state of the object will be returned.

    • Function

      enableReifect

      Parameters

      Returns this

      • Itself, allowing for method chaining.

      Set the reifect enabled state of this object. If a reifect is provided, the enabled state of the object for this specific reifect will be updated. otherwise, the global state of the object will be updated

    • Function

      setStyle

      Parameters

      • attribute: keyof CSSStyleDeclaration

        A string representing the style attribute to set.

      • value: string | number

        THe value to append.

      • Optionalinstant: boolean

        If true, will set the fields directly. Otherwise, will set them on next animation frame.

      Returns this

      Itself, allowing for method chaining.

      Set a certain style attribute of the element to the provided value.

    • Function

      appendStyle

      Parameters

      • attribute: keyof CSSStyleDeclaration

        A string representing the style attribute to append to.

      • value: string | number

        The value to append.

      • Optionalseparator: string

        The separator to use between the existing and new values.

      • Optionalinstant: boolean

        If true, will set the fields directly. Otherwise, will set them on next animation frame.

      Returns this

      Itself, allowing for method chaining.

      Append the provided value to a certain style attribute.

    • Function

      setStyles

      Parameters

      • styles: StylesType

        Acceptable styles to set.

      • Optionalinstant: boolean

        If true, will set the fields directly. Otherwise, will set them on next animation frame.

      Returns this

      Itself, allowing for method chaining.

      Parses and applies the given CSS to the element's inline styles.

    • Function

      makeSubstrate

      Parameters

      • name: string

        The name of the new substrate.

      • Optionaloptions: MakeSubstrateOptions

        Options parameter to configure the newly-created substrate.

      Returns this

      • Itself for chaining.

      Creates a new substrate attached to this element. Useful to maintain certain constraints or ensure some behaviors persist on a list of objects (by attaching solvers to this substrate).

    • Function

      onSubstrateActivate

      Parameters

      • Optionalsubstrate: string

        The name of the targeted substrate. Defaults to the current substrate.

      Returns Delegate<() => void>

      • The delegate.

      Get the delegate fired when the substrate of the given name is activated (set as currentSubstrate).

    • Function

      onSubstrateDeactivate

      Parameters

      • Optionalsubstrate: string

        The name of the targeted substrate. Defaults to the current substrate.

      Returns Delegate<() => void>

      • The delegate.

      Get the delegate fired when the substrate of the given name is deactivated.

    • Function

      getSubstrateObjectList

      Parameters

      • Optionalsubstrate: string

        The name of the targeted substrate. Defaults to the current substrate.

      Returns Set<object>

      Retrieve the list of objects that are constrained by the given substrate.

    • Function

      setSubstrateObjectList

      Parameters

      • list: Set<object> | HTMLCollection | NodeList

        The list of objects to constrain.

      • Optionalsubstrate: string

        The name of the targeted substrate. Defaults to the current substrate.

      Returns this

      • Itself for chaining.

      Set the list of objects that are constrained by the given substrate.

    • Function

      addObjectToSubstrate

      Parameters

      • object: object

        The object to add to the list.

      • Optionalsubstrate: string

        The name of the targeted substrate. Defaults to the current substrate.

      Returns this

      • Itself for chaining.

      Adds the given object to the substrate's list.

    • Function

      removeObjectFromSubstrate

      Parameters

      • object: object

        The object to remove from the list.

      • Optionalsubstrate: string

        The name of the targeted substrate. Defaults to the current substrate.

      Returns this

      • Itself for chaining.

      Removes the given object from the substrate's list.

    • Function

      hasObjectInSubstrate

      Parameters

      • object: object

        The object to check.

      • Optionalsubstrate: string

        The name of the targeted substrate. Defaults to the current substrate.

      Returns boolean

      • Whether the object is in the list or not.

      Check if the given object is in the substrate's object list.

    • Function

      wasObjectProcessedBySubstrate

      Parameters

      • object: object

        The object to check.

      • Optionalsubstrate: string

        The name of the targeted substrate. Defaults to the current substrate.

      Returns boolean

      • Whether the object was processed or not.

      Check whether the given object was already processed by the substrate in the current resolving loop (resolveSubstrate). Can be useful in solvers.

    • Function

      addSolver

      Parameters

      • fn: SubstrateSolver

        The solver function to execute when calling resolveSubstrate.

      • Optionalsubstrate: string

        The name of the targeted substrate. Defaults to the current substrate.

      Returns this

      • Itself for chaining.

      Add the given function as a solver in the substrate.

    • Function

      removeSolver

      Parameters

      • fn: SubstrateSolver

        The solver function to remove.

      • Optionalsubstrate: string

        The name of the targeted substrate. Defaults to the current substrate.

      Returns this

      • Itself for chaining.

      Remove the given function from the substrate's list of solvers.

    • Function

      clearSolvers

      Parameters

      • Optionalsubstrate: string

        The name of the targeted substrate. Defaults to the current substrate.

      Returns this

      • Itself for chaining.

      Remove all solvers attached to the substrate.

    • Function

      resolveSubstrate

      Parameters

      • Optionalproperties: SubstrateSolverProperties

        Options object to configure the context of the resolving call.

      • Optionalsubstrate: string

        The name of the targeted substrate. Defaults to the current substrate.

      Returns this

      Resolve the substrate by executing all of its attached solvers. Each solver will be executed on every object in the substrate's list of constrained objects, marking each as processed as it goes through them.

    • Function

      makeTool

      Parameters

      • toolName: string

        The unique name of the tool to register under the manager. Reusing an existing toolName will make this element another instance of toolName.

      • Optionaloptions: MakeToolOptions

        Tool creation options (custom activation, click mode, key mapping, manager).

      Returns this

      • Itself for chaining.

      Turns the element into a tool identified by toolName, optionally wiring activation and key mapping. By default, this function also sets up an event listener on the element to activate the tool on click. This behavior can be overridden via the options parameter.

    • Function

      isTool

      Parameters

      • Optionalmanager: TurboEventManager

        The associated event manager (defaults to TurboEventManager.instance).

      Returns boolean

      True if the element is a tool, false otherwise.

      Whether this element is registered as a tool for the provided manager.

    • Function

      getToolNames

      Parameters

      • Optionalmanager: TurboEventManager

        The associated event manager (defaults to TurboEventManager.instance).

      Returns string[]

      The list of tool names.

      Returns all tool names registered on this element for the provided manager.

    • Function

      getToolName

      Parameters

      • Optionalmanager: TurboEventManager

        The associated event manager (defaults to TurboEventManager.instance).

      Returns string

      The first tool name, if any.

      Returns the first registered tool name on this element for the provided manager.

    • Function

      onToolActivate

      Parameters

      • OptionaltoolName: string

        The name of the tool.

      • Optionalmanager: TurboEventManager

        The associated event manager (defaults to TurboEventManager.instance).

      Returns Delegate<() => void>

      • The delegate.

      Retrieve the delegate fired when this tool is activated in the corresponding manager.

    • Function

      onToolDeactivate

      Parameters

      • OptionaltoolName: string

        The name of the tool.

      • Optionalmanager: TurboEventManager

        The associated event manager (defaults to TurboEventManager.instance).

      Returns Delegate<() => void>

      • The delegate.

      Retrieve the delegate fired when this tool is deactivated in the corresponding manager.

    • Function

      addToolBehavior

      Parameters

      • type: string

        The type of the event (e.g., "pointerdown", "click", custom turbo event).

      • callback: ToolBehaviorCallback

        The behavior function. Return true to stop propagation.

      • OptionaltoolName: string

        Tool name to bind the behavior to. Defaults to this element's first tool.

      • Optionalmanager: TurboEventManager

        The associated event manager (defaults to TurboEventManager.instance).

      Returns this

      Itself for chaining.

      Adds a behavior callback for a given tool and a given type. This callback will attempt to be executed on the target element when a type event is fired and toolName is active. It is applied to all instances of the tool.

    • Function

      hasToolBehavior

      Parameters

      • type: string

        The type of the event (e.g., "pointerdown", "click", custom turbo event).

      • OptionaltoolName: string

        The tool name to check under. Defaults to this element's first tool.

      • Optionalmanager: TurboEventManager

        The associated event manager (defaults to TurboEventManager.instance).

      Returns boolean

      True if one or more behaviors are registered.

      Checks whether there is at least one tool behavior for the pair "type, toolName."

    • Function

      removeToolBehaviors

      Parameters

      • type: string

        The type of the event (e.g., "pointerdown", "click", custom turbo event).

      • OptionaltoolName: string

        The tool name whose behaviors will be removed. Defaults to this element's first tool.

      • Optionalmanager: TurboEventManager

        The associated event manager (defaults to TurboEventManager.instance).

      Returns this

      Itself for chaining.

      Removes all behaviors for the pair "type, toolName" under the given manager.

    • Function

      applyTool

      Parameters

      • toolName: string

        The name of the tool whose behaviors should run.

      • type: string

        The type of the event (e.g., "pointerdown", "click", custom turbo event).

      • event: Event

        The triggering event instance.

      • Optionalmanager: TurboEventManager

        The associated event manager (defaults to TurboEventManager.instance).

      Returns boolean

      True if at least one behavior returned true (to stop propagation of the event).

      Executes all behaviors registered for the pair "type, toolName" against this element.

    • Function

      clearToolBehaviors

      Parameters

      • Optionalmanager: TurboEventManager

        The associated event manager (defaults to TurboEventManager.instance).

      Returns this

      Itself for chaining.

      Clears all registered behaviors for the tools attached to this element.

    • Function

      embedTool

      Parameters

      • target: Node

        The node to manipulate when interacting with the tool element itself.

      • Optionalmanager: TurboEventManager

        The associated manager (defaults to TurboEventManager.instance).

      Returns this

      Itself for chaining.

      Embeds this tool into a target node, so all interactions on the tool element apply to the defined target.

    • Function

      isEmbeddedTool

      Parameters

      • Optionalmanager: TurboEventManager

        The associated manager (defaults to TurboEventManager.instance).

      Returns boolean

      True if an embedded target is present.

      Whether this tool is embedded under the provided manager.

    • Function

      getEmbeddedToolTarget

      Parameters

      • Optionalmanager: TurboEventManager

        The associated manager (defaults to TurboEventManager.instance).

      Returns Node

      The embedded tool's target node, if any.

      Returns the target node for this embedded tool under the provided manager.

    • Function

      ignoreTool

      Parameters

      • toolName: string

        The name of the tool to ignore.

      • Optionaltype: string

        The type of the event. If undefined, all event types will be considered.

      • Optionalignore: boolean

        Whether to ignore the tool. Defaults to true.

      • Optionalmanager: TurboEventManager

        The associated manager (defaults to TurboEventManager.instance).

      Returns this

      Itself for chaining.

      Make the current element ignore the provided tool, so interacting with the tool on this element will have no effect and propagate.

    • Function

      ignoreTool

      Parameters

      • Optionalignore: boolean

        Whether to ignore the tools. Defaults to true.

      • Optionalmanager: TurboEventManager

        The associated manager (defaults to TurboEventManager.instance).

      Returns this

      Itself for chaining.

      Make the current element ignore all tools, so interacting with any tool on this element will have no effect and propagate.

    • Function

      isToolIgnored

      Parameters

      • toolName: string

        The name of the tool to check for.

      • Optionaltype: string

        The type of the event. If undefined, all event types will be considered.

      • Optionalmanager: TurboEventManager

        The associated manager (defaults to TurboEventManager.instance).

      Returns boolean

      Whether the tool is ignored for the provided event type.

      Whether the current element is ignoring the provided tool.