webchalk-animate - v0.31.0
    Preparing search index...
    Index

    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

    • Removes a number of AnimSequence objects from the timeline based on the provided indices range (0-based).

      Parameters

      • startIndex: number

        The starting index, inclusive.

      • endIndex: number = ...

        The ending index, exclusive (if not specified, startIndex + 1 is used, removing one sequence).

      Returns AnimSequence[]

      An array containing the sequences that were removed from the timeline.

    Properties

    generateError: TimelineErrorGenerator = ...
    id: number

    A 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 scheduleTask generated by AnimClip.scheduleTask.
      • (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 } = {}

        An options object 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

          An 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

        The 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;
        } = {}

        An options object 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

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

        • OptionaltargetOffset?: number

          An 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} = webchalk.createAnimationClipFactories();
      const square = document.querySelector('.square');

      const tLine = webchalk.newTimeline(
      [
      webchalk.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}),
      ]
      ),

      webchalk.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'}]),
      ]
      ),

      webchalk.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" } = {}

        An options object specifying the behavior 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 <webchalk-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 <webchalk-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 } = {}

        An object containing settings to define the behavior of the search

        • OptionalbuttonsSubset?: PlaybackButtonPurpose[]

          An 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