Add new easing function generators: generateBack, generateElastic, generateSteps - #711
Open
0xTHAC0 wants to merge 1 commit into
Open
Add new easing function generators: generateBack, generateElastic, generateSteps#7110xTHAC0 wants to merge 1 commit into
0xTHAC0 wants to merge 1 commit into
Conversation
…nerateSteps Adds three new configurable easing generators to complement the existing generatePow, as requested in tweenjs#507: - generateBack(overshoot): Back easing with custom overshoot (default 1.70158) - generateElastic(amplitude, period): Elastic easing with configurable amplitude and period - generateSteps(steps): Discrete step easing for staircase animations All generators return EasingFunctionGroup (In/Out/InOut) and satisfy the standard edge-value contracts (f(0)=0, f(1)=1, InOut(0.5)=0.5). Includes unit tests and updates the graphs example with visual demos. Closes tweenjs#507 Co-Authored-By: Paperclip <noreply@paperclip.ing>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds three new configurable easing generators to complement the existing
generatePow, as requested in #507:generateBack(overshoot)— Back easing with custom overshoot (default1.70158, matching the built-inBack). Higher values produce more dramatic overshoots.generateElastic(amplitude, period)— Elastic easing with configurable amplitude (≥1) and period. Useful for springy animations where you need fine control over the bounce.generateSteps(steps)— Discrete step easing that quantizes the animation into N steps. In variant jumps at the start of each interval, Out at the end, InOut combines both halves. Useful for sprite sheet animations and staircase effects.All generators return
EasingFunctionGroup(In/Out/InOut) and satisfy the standard edge-value contracts:f(0) = 0f(1) = 1InOut(0.5) = 0.5Changes
src/Easing.ts— added the three generator functionssrc/tests.ts— added 7 test cases covering edge values, discrete step behavior, midpoint constraints, andgenerateBackparity with defaultBackexamples/03_graphs.html— added visual demos for the new generatorsUsage
Closes #507