Class Spin


public class Spin extends Animation
A looping animation that continuously rotates an element 360 degrees.

The element spins smoothly at a constant speed. This is commonly used for loading spinners and processing indicators. The default duration is 2000ms (speed 0) for a calm, steady rotation.

SpinPulse reuses the same keyframes but applies a stepped timing function for a discrete, pulsing rotation effect.

Usage:


 // Default smooth spin (2 seconds per rotation)
 spinner.animate(new Spin());

 // Faster spin
 spinner.animate(new Spin().setSpeed(5));
 
Since:
2026
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Spin

      public Spin()
      Constructs a Spin animation with speed 0 (2000ms per rotation).
  • Method Details

    • getKeyFramesId

      public String getKeyFramesId()
      Returns the unique ID for this animation's keyframes style element.

      This ID is used to deduplicate keyframe injection into the page head. Subclasses with configurable keyframes (e.g., Beat with a custom scale) should return a unique ID per configuration to avoid collisions.

      Specified by:
      getKeyFramesId in class Animation
      Returns:
      the keyframes style element ID
    • createKeyFrames

      public KeyFrames createKeyFrames()
      Creates the @keyframes definition for this animation.
      Specified by:
      createKeyFrames in class Animation
      Returns:
      a KeyFrames object defining the animation sequence
    • getDefaultTimingFunction

      protected AnimationTimingFunction getDefaultTimingFunction()
      Returns the default timing function for this animation.

      Each animation subclass provides its own default timing function. For custom cubic-bezier or steps timing, override Animation.getTimingFunctionValue() instead.

      Specified by:
      getDefaultTimingFunction in class Animation
      Returns:
      the default timing function, or null if Animation.getTimingFunctionValue() provides a custom value