Structure

Methods that relate to building the timeline or locating sequences within it.

Properties

Property Getter Methods

Methods that return objects that contain various internal fields of the timeline (such as isPaused from getStatus()).

Playback Methods

Methods that control the playback of the animation timeline.

Configuration

Methods

Playback UI

Structure

  • Finds the index of a given AnimSequence object within the timeline

    Parameters

    • animSequence: AnimSequence

      the animation sequence to search for within the timeline

    Returns number

    the index of animSequence within the timeline or -1 if the sequence is not part of the timeline.

Properties

generateError: TimelineErrorGenerator = ...
id: number

Number that uniquely identifies the timeline from other timelines. Automatically generated.

Property Getter Methods

Playback Methods

  • Forces the animation sequences that are currently running within the timeline to instantly finish.

    • After the currently running animation sequences complete, the rest of the timeline runs normally.
    • The timeline will still pause for any roadblocks generated by AnimClip.addRoadblocks.
    • (Currently, only 1 sequence can play at a time in a timeline, so by "sequences", we just mean "sequence").

    Returns Promise<AnimTimeline>

  • Jumps instantly to the position within the timeline based on the position argument.

    Parameters

    • position: number | "end" | "beginning"

      the target position within the timeline

    • options: {
          autoplayDetection?: "none" | "forward" | "backward";
          targetOffset?: number;
      } = {}

      set of options defining the offset of the jump and whether to consider autoplay

      • OptionalautoplayDetection?: "none" | "forward" | "backward"

        determines how the timeline should handle sequences set to autoplay once the jump destination (after considering options.targetOffset) has been reached

        • if 'none', the timeline stays at the final landing position after the initial jumping operation.
        • if 'forward', the timeline will jump forward for as long as the next sequence is supposed to autoplay after the current sequence.
        • if 'backward', the timeline will jump backward for as long as the previous sequence as long as the previous sequence is supposed to automatically rewind after the current sequence is rewound (this is naturally only true when the current sequence is set to autoplay when the timeline steps forward).
        'none'
        
      • OptionaltargetOffset?: number

        offset that adds to the initial landing position

    Returns Promise<AnimTimeline>

    a Promise that resolves when the timeline has finished jumping.

  • Jumps instantly to the sequence whose AnimSequence.getJumpTag() value matches the jumpTag argument.

    Parameters

    • jumpTag: string | RegExp

      string that is used to search for the target sequence with the matching AnimSequence.getJumpTag() value

    • options: {
          autoplayDetection?: "none" | "forward" | "backward";
          search?:
              | "forward"
              | "backward"
              | "forward-from-beginning"
              | "backward-from-end";
          searchOffset?: number;
          targetOffset?: number;
      } = {}

      set of options defining the behavior of the search, the offset of the jump, and whether to consider autoplay

      • OptionalautoplayDetection?: "none" | "forward" | "backward"

        determines how the timeline should handle sequences set to autoplay once the jump destination (after considering options.targetOffset) has been reached

        • if 'none', the timeline stays at the final landing position after the initial jumping operation.
        • if 'forward', the timeline will jump forward for as long as the next sequence is supposed to autoplay after the current sequence.
        • if 'backward', the timeline will jump backward for as long as the previous sequence is supposed to automatically rewind after the current sequence is rewound (this is naturally only true when the current sequence is set to autoplay when the timeline steps forward).
        'none'
        
      • Optionalsearch?:
            | "forward"
            | "backward"
            | "forward-from-beginning"
            | "backward-from-end"

        the direction and/or the starting point of the search

        'forward-from-beginning'
        
      • OptionalsearchOffset?: number

        offset that changes the starting point of the search by the indicated amount

      • OptionaltargetOffset?: number

        offset that adds to the initial landing position

    Returns Promise<AnimTimeline>

    a Promise that resolves when the timeline has finished jumping.

    const {Entrance, Motion, Exit} = webimator.createAnimationClipFactories();
    const square = document.querySelector('.square');

    const tLine = webimator.newTimeline(
    webimator.newSequence(
    {jumpTag: 'flickering'},
    Entrance(square, '~appear', [], {endDelay: 500}),
    Exit(square, '~disappear', [], {endDelay: 500}),
    Entrance(square, '~appear', [], {endDelay: 500}),
    Exit(square, '~disappear', [], {endDelay: 500}),
    Entrance(square, '~appear', [], {endDelay: 500}),
    Exit(square, '~disappear', [], {endDelay: 500}),
    ),

    webimator.newSequence(
    {jumpTag: 'move around'},
    Motion(square, '~translate', [{translate: '200px, 0px'}]),
    Motion(square, '~translate', [{translate: '0px, 200px'}]),
    Motion(square, '~translate', [{translate: '-200px, 0px'}]),
    Motion(square, '~translate', [{translate: '0px, -200px'}]),
    ),

    webimator.newSequence(
    {jumpTag: 'go away', autoplays: true},
    Exit(square, '~pinwheel', []),
    )
    );

    // Promise-based timer
    async function wait(milliseconds: number) {
    return new Promise(resolve => setTimeout(resolve, milliseconds));
    }

    (async () => {
    // jump straight to sequence with tag "move around"
    await tLine.jumpToSequenceTag('move around');

    await wait (1000); // wait 1 second

    // jump to sequence whose tag contains "flick"
    // (so now we're back at the beginning of the timeline)
    await tLine.jumpToSequenceTag(/flick/);

    await wait (1000); // wait 1 second

    // jump to sequence with tag "move around"
    // then look forward to see if any sequences have {autoplays: true}
    // the next one does, so it continues, skipping to the third sequence
    await tLine.jumpToSequenceTag('move around', {autoplayDetection: 'forward'});

    await wait (1000); // wait 1 second

    // play the last sequence
    await tLine.step('forward');
    })();
  • Pauses the animation timeline if it is unpaused or unpauses it if it is currently paused.

    Parameters

    • options: {
          forceState?: "pause" | "unpause";
      } = {}

      options for the bevior of the toggle

      • OptionalforceState?: "pause" | "unpause"

        Explicitly instructs the method to either pause (equivalent to pause()) or unpause (equivalent to unpause())

    Returns this

Configuration

Methods

Playback UI

  • get playbackButtons(): Readonly<PlaybackButtons>
  • Object containing properties that are either references to <wbmtr-playback-button> elements that are connected to this timeline or null.

    • A property being null indicates that there is currently no corresponding button on the page that is linked to this timeline.

    Returns Readonly<PlaybackButtons>

  • Searches the page for <wbmtr-playback-button> elements whose timeline-name attributes are equivalent to this timeline's timelineName configuration option, then links those buttons to this timeline.

    • By default, all button types are searched for.

    Parameters

    • options: {
          buttonsSubset?: PlaybackButtonPurpose[];
          searchRoot?: HTMLElement;
      } = {}

      Settings to define the behavior of the search

      • OptionalbuttonsSubset?: PlaybackButtonPurpose[]

        Array of strings indicating which specific buttons we want to link. By default, all buttons are searched for

      • OptionalsearchRoot?: HTMLElement

        The HTML element from which to begin searching for the buttons

    Returns this