Tween

Allows tweening Object properties between two states for a given duration. To tween properties on Paper.js Item instances, item.tween(from, to, options) can be used, which returns created tween instance.

Constructors

  • Tween(object, from, to, duration[, easing[, start]])

    Creates a new tween.

    • Parameters:

    • object: Object β€” the object to tween the properties on

    • from: Object β€” the state at the start of the tweening

    • to: Object β€” the state at the end of the tweening

    • duration: Number β€” the duration of the tweening

    • easing: StringβŸ‹Function β€” the type of the easing function or the easing function β€” optional, default: β€˜linear’

    • start: Boolean β€” whether to start tweening automatically β€” optional, default: true

    • Returns:

    • Tween β€” the newly created tween

Properties

Event Handlers

  • onUpdate

    The function to be called when the tween is updated. It receives an object as its sole argument, containing the current progress of the tweening and the factor calculated by the easing function.

    • Type:

    • FunctionβŸ‹null

    Example:Display tween progression values:

Methods

  • then(function)

    Set a function that will be executed when the tween completes.

    • Parameters:

    • function: Function β€” the function to execute when the tween completes

    • Returns:

    • Tween

    Example:Tweens chaining:

  • start()

    Start tweening.

    • Returns:

    • Tween

    Example:Manually start tweening.

  • stop()

    Stop tweening.

    • Returns:

    • Tween

    Example:Stop a tween before it completes.

Was this helpful?