Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SwayEasing

Hierarchy

Index

Constructors

constructor

Properties

alpha

alpha: number

bounces

bounces: number = 4

limit

limit: number

omega

omega: number

stiffness

stiffness: number = 3

Methods

calculate

  • calculate(ratio: number): number

calculateOmega

  • calculateOmega(bounces: number, limit: number): number

exponent

  • exponent(t: number): number

findOptimalKeyPoints

  • findOptimalKeyPoints(threshold?: number, resolution?: number): number[]
  • Find the optimal keypoints to approximate the easing curve with line segments. This is done in two steps:

    1. Set keypoints at the start, end and turning points of the curve

    2. For each pair of subsequent keypoints, compare the area between the curve and a straight line between these keypoints. If it is above a given threshold, insert a new keypoint in the middle of these two. This process is repeated until the area has been reduced below the threshold for all pairs of subsequent keypoints.

    Parameters

    • Default value threshold: number = 1
    • Default value resolution: number = 1000

    Returns number[]

oscillation

  • oscillation(t: number): number

serialize

  • serialize(): { bounces: number; stiffness: number }