Professional Documentation for SelectJs Animation Engine

Introduction

In the world of web development, movements and transitions are an essential part of enhancing the user experience, making interfaces more lively and interactive. High-performance animations require execution precision, customization flexibility, and ease of use. This is where the SelectJs library comes in as an advanced solution for creating smooth, natural, and flexible animations on DOM elements, with full support for interactions and events.

Library Overview

SelectJs is an open-source JavaScript library designed to provide a high-performance animation engine based on best coding practices. It aims to empower developers to design complex and smooth animations without the need to write extensive code, while ensuring compatibility with all browsers, including older ones.

Advanced Features

Why choose SelectJs?

Core Features of the Library

Feature Description
High Performance Relies on requestAnimationFrame for smooth updates.
High Flexibility Supports animating CSS properties, Transforms, colors, and compound values.
Full Customization Control over duration, easing, looping, delays, and events.
Dynamic Interactivity Links animations to user events like clicks and scrolls.
Data Protection Uses deep cloning to ensure data integrity during modifications.
Easing Functions Wide range of easing options for natural movements.
Ease of Use Simple API with support for multiple components.

Library Components and Functions

1. Element Selection (selectDom)

2. Animation Setup (animate)

3. Supported Properties & Colors

4. Timing & Loop Control

5. Interactive Features

6. Easing Functions

7. Looping Modes (boucleType)

This property controls how animations loop. The four main modes are:

  1. return:
    Plays from start to end, then immediately jumps back to start, repeating endlessly.
  2. repeat:
    Plays from start to end, then jumps back to start, repeating.
  3. returnRepeat:
    Plays forward, then reverses back (ping-pong), then repeats.
  4. repeatReturn:
    Repeats forward, then jumps back to start.
animate(element, {
  property: 'left',
  from: '0px',
  to: '300px',
  duration: 1000,
  boucleType: 'return' // or 'repeat', 'returnRepeat', 'repeatReturn'
});

8. Event-Based Control

Control animations via user interactions:

pause: ['.element', 'e:click|true']

Understanding Looping Modes: The Four boucleType Cases

In configuring animations, boucleType controls how the animation repeats. The four main modes are:

  1. return:
    Plays from start to end, then jumps immediately back to start, creating a continuous loop.
  2. repeat:
    Similar to 'return' but may involve different behaviors for specific implementations.
  3. returnRepeat:
    Plays forward, then reverses back (ping-pong), then repeats.
  4. repeatReturn:
    Repeats forward, then jumps back to start, then repeats again.

Example usage:

animate(element, {
  property: 'left',
  from: '0px',
  to: '300px',
  duration: 1000,
  boucleType: 'return' // or 'repeat', 'returnRepeat', 'repeatReturn'
});

Conclusion

Understanding and properly configuring boucleType allows you to create diverse looping behaviors, making your UI more dynamic and engaging.