Skip to content

[FEATURE] Increase spring stiffness and velocity limits for realistic physics (#1039) #1040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

lixiaolin94
Copy link

Summary

This PR implements the feature request from issue #1039 to increase the
maximum limits for spring animation stiffness and velocity parameters,
enabling more realistic physics-based animations.

Changes

  • Stiffness limit: Increased from 1,000 to 10,000 (10x increase)
  • Velocity limit: Increased from ±1,000 to ±10,000 (10x increase)
  • Updated both constructor and setter methods to use new limits
  • Added comprehensive test coverage for the new limits
  • Fixed rollup configuration import syntax for better Node.js
    compatibility

Example Usage

// Now possible with increased limits
anime({
  targets: '.element',
  translateX: 250,
  easing: 'spring(1, 5000, 10, 2000)' // High stiffness and velocity
});

Test Plan

- All existing tests continue to pass
- New tests added for stiffness limits up to 10,000
- New tests added for velocity limits up to ±10,000
- Tests verify values above limits are properly clamped
- Tests confirm animations work with high parameter values
- Build process (npm run dev-types) works correctly
- Browser tests run successfully

Breaking Changes

None - this change is fully backward compatible.

Performance Impact

No performance regression expected. The change only increases upper
bounds while maintaining the same clamping behavior.

Closes #1039

juliangarnier and others added 5 commits April 24, 2025 10:48
- Increase stiffness limit from 1,000 to 10,000 (10x increase)
- Increase velocity limit from ±1,000 to ±10,000 (10x increase)
- Update both constructor and setter methods with new limits
- Add comprehensive tests for increased limits and clamping behavior
- Fix rollup config import syntax for better Node.js compatibility

Enables more realistic physics-based spring animations while maintaining
backward compatibility and reasonable upper bounds for performance.

Closes juliangarnier#1039
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants