Tweeny 4.1.0
A Tweening library for modern C++
Loading...
Searching...
No Matches

◆ elasticInOut

detail::elasticInOutEasing elasticInOut {}
inlineconstexpr

Elastic easing combining spring oscillation at both start and end.

The elasticInOut easing function creates dramatic elastic motion with oscillation during both the initial acceleration and final deceleration phases. The animation winds up with spring-like vibration, accelerates smoothly through the middle, then oscillates around the target before settling.

The motion profile:

  • First half: Oscillates with increasing amplitude (elasticIn behavior)
  • Middle: Smooth transition through the midpoint
  • Second half: Oscillates with decreasing amplitude (elasticOut behavior)
  • Creates the most dramatic elastic effect available

This easing is appropriate for:

  • Hero animations: Focal transitions that demand attention
  • Game events: Critical moments, boss appearances, dramatic reveals
  • Cartoon physics: Exaggerated, entertaining motion for stylized visuals
  • Transitions with flair: Scene changes that need maximum personality
  • Experimental UI: Interfaces prioritizing delight over convention

ElasticInOut is the most expressive elastic variant but also the most extreme. It works best for animations that are:

  • Intentionally playful or whimsical
  • The primary focus of user attention
  • Part of a stylized, high-energy aesthetic
  • Not repeated frequently (can become tiresome)

Use sparingly; the dual oscillation can feel excessive for everyday interactions. Consider elasticOut or backInOut for a more balanced alternative.

Warning
This easing produces extreme value overshoots in both directions throughout the animation. During the first half, values oscillate around the start; during the second half, around the target. Plan for values far outside the expected range.
// Dramatic screen transition
auto position = tweeny::from(0.0f)
.to(1920.0f)
.during(90U)
.build();
// Position will oscillate around 0.0f at start and 1920.0f at end
// Game title appearing with maximum impact
auto scale = tweeny::from(0.0f)
.to(2.0f)
.during(75U)
.build();
tweeny_builder< true, FirstValue, RemainingValues... > to(const FirstValue &firstComponent, const RemainingValues &... remainingComponents) &
Adds a target keyframe to the tween.
Definition tweeny.h:109
tweeny_builder & via(EasingFunctionTypes... easing_functions)
Specifies per-component easing functions for the last keyframe segment.
Definition tweeny.h:198
constexpr detail::elasticInOutEasing elasticInOut
Elastic easing combining spring oscillation at both start and end.
Definition easing.h:738
tweeny_builder< false, FirstValue, RemainingValues... > from(FirstValue firstComponent, RemainingValues... remainingComponents)
Creates a new tween builder starting from the specified value(s).
Definition tweeny.h:347
See also
elasticIn For oscillation only at the start
elasticOut For oscillation only at the end (more commonly useful)
backInOut For a less extreme but still expressive alternative
Visualize at https://easings.net/#easeInOutElastic