Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Slider

Make all <input[type='range']> with an action name interactive.

In index.html:

<label for="samples">Samples:</label>
<input type="range" id="samples" value="1000" min="100" max="10000" step="100" />

In analysis.py:

@ databench.on
def samples(self, value):
    """Sets the number of samples to generate per run."""
    yield self.set_state(samples=value)

Hierarchy

Index

Constructors

constructor

Properties

actionName

actionName: string

idCount

idCount: number

labelHtml

labelHtml: string

labelNode

labelNode: HTMLElement | undefined

node

node: HTMLInputElement & HTMLDatabenchElement

wireSignal

wireSignal: string | object

Static idCounter

idCounter: number = 0

Methods

actionFormat

  • actionFormat(value: any): any
  • Formats the payload of an action.

    Parameters

    • value: any

      Original payload.

    Returns any

    Modified payload.

change

  • change(): void

changeCB

  • changeCB(value: number): void
  • Callback with changes to the slider value.

    Parameters

    • value: number

      Value from a sliderToValue() transform.

    Returns void

determineActionName

  • determineActionName(node: HTMLElement): string
  • Determine the name of the action that should be associated with the node.

    The action name is determined from the tag's data-action, name or id attribute (in that order).

    Parameters

    • node: HTMLElement

      A HTML element.

    Returns string

    Name of action or null.

determineWireSignal

  • determineWireSignal(node: HTMLElement): string | object
  • Determine the name of the signal that should be listened to from the backend.

    The signal name is determined from the data-signal, data-action, name or id attribute (in that order.) For all attributes apart from data-signal, the value is wrapped in an object like { data: value-of-attribute }. The data-signal value can contain a : which will be used to create an object as well. That means that data-signal="data:myvalue" gives the same result as data-action="myvalue".

    Parameters

    • node: HTMLElement

      A HTML element.

    Returns string | object

    Name of a signal or null.

formatFn

  • formatFn(value: number): string
  • How a value should be represented. For example, this can add units or convert from radians to degrees.

    Parameters

    • value: number

      Input value as it is stored in the backend.

    Returns string

    Representation of a value.

getValue

  • getValue(): number
  • Reads the value.

    Returns number

render

setValue

sliderToValue

  • sliderToValue(s: number): number
  • Transform a value from the HTML range element to a value that should be stored.

    Parameters

    • s: number

      Value from HTML range element.

    Returns number

    Value to store.

valueToSlider

  • valueToSlider(value: number): string
  • Transform a backend value to a slider value.

    Parameters

    • value: number

      Value as stored in backend.

    Returns string

    Value for the HTML range element.

Static labelsForSliders

  • labelsForSliders(root: Document | HTMLElement): object
  • Find all labels for slider elements.

    Parameters

    • root: Document | HTMLElement

    Returns object

    • [inputname: string]: HTMLLabelElement

Static skipWire

  • skipWire(node: HTMLElement): boolean
  • Determine whether to skip this element.

    This can be forced by adding a data-skipwire=true attribute to the HTML tag.

    Parameters

    • node: HTMLElement

      A HTML element.

    Returns boolean

Static wire

  • wire(conn: Connection, root?: Document | HTMLElement): void
  • Wire all sliders.

    Parameters

    • conn: Connection
    • Optional root: Document | HTMLElement

    Returns void

Generated using TypeDoc