Daniel Toranzo Pérez

Daniel Toranzo Pérez

Herramientas Tools

Visualizador de springs de SwiftUI SwiftUI spring visualizer

Presets Presets
Cómo leer la curva How to read the curve
  • bounce = 0: críticamente amortiguado, sin rebote.
  • bounce > 0: rebota; cuanto mayor, más oscilaciones.
  • bounce < 0: sobreamortiguado, llega más lento sin rebotar.
  • La herramienta limita bounce a -0.99: en -1 el amortiguamiento tiende a infinito y SwiftUI puede devolver NaN.
  • dampingFraction < 1: rebota; 1: crítico; > 1: sobreamortiguado.
  • duration y response están en segundos: menos tiempo, más rápido.
  • initialVelocity positivo empuja hacia el destino; negativo, en contra.
  • bounce = 0: critically damped, with no bounce.
  • bounce > 0: bounces; the higher the value, the more oscillations.
  • bounce < 0: overdamped, arriving more slowly without bouncing.
  • The tool caps bounce at -0.99: at -1 the damping tends to infinity and SwiftUI can return NaN.
  • dampingFraction < 1: bounces; 1: critical; > 1: overdamped.
  • duration and response are in seconds: less time means a faster spring.
  • Positive initialVelocity pushes toward the target; negative pushes against it.
SwiftUI
—

Aproximación visual basada en el modelo de resorte amortiguado de SwiftUI. El snippet asume una propiedad isExpanded. .spring(duration:bounce:) requiere iOS 17; confirma el resultado final en un dispositivo.

A visual approximation based on SwiftUI’s damped spring model. The snippet assumes an isExpanded property. .spring(duration:bounce:) requires iOS 17; check the final result on a device.

Cómo se calcula How it is calculated

La curva resuelve la ecuación de un resorte amortiguado. Para duration/bounce y response/dampingFraction se normaliza con masa 1; la frecuencia natural y el amortiguamiento se obtienen así:

  • duration/bounce: ω = 2π / duration; ζ = 1 − bounce si bounce ≥ 0, o ζ = 1 / (1 + bounce) si bounce < 0.
  • response/dampingFraction: ω = 2π / response; ζ = dampingFraction.
  • interpolatingSpring: ω = √(stiffness / mass); ζ = damping / (2√(stiffness · mass)).

Para animaciones no interrumpidas, la curva coincide con Spring.value(target:initialVelocity:time:) de SwiftUI. Las diferencias prácticas aparecen con blendDuration, velocidad heredada o retargeting. El tiempo de asentamiento usa una tolerancia de ±0.005. Animate with springs (WWDC23).

The curve solves the damped spring equation. For duration/bounce and response/dampingFraction, it normalizes with mass 1; the natural frequency and damping ratio are derived like this:

  • duration/bounce: ω = 2π / duration; ζ = 1 − bounce when bounce ≥ 0, or ζ = 1 / (1 + bounce) when bounce < 0.
  • response/dampingFraction: ω = 2π / response; ζ = dampingFraction.
  • interpolatingSpring: ω = √(stiffness / mass); ζ = damping / (2√(stiffness · mass)).

For uninterrupted animations, the curve matches SwiftUI’s Spring.value(target:initialVelocity:time:). Practical differences appear with blendDuration, inherited velocity, or retargeting. Settling time uses a ±0.005 tolerance. Animate with springs (WWDC23).