-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "back" easings, fix error in elastic easings
- Loading branch information
Showing
8 changed files
with
127 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
///<reference path="easings.ts" /> | ||
/* | ||
* VelocityJS.org (C) 2014-2017 Julian Shapiro. | ||
* | ||
* Licensed under the MIT license. See LICENSE file in the project root for details. | ||
* | ||
* Back easings, based on code from https://github.com/yuichiroharai/easeplus-velocity | ||
*/ | ||
|
||
namespace VelocityStatic.Easing { | ||
export function registerBackIn(name: string, amount: number) { | ||
registerEasing([name, function(percentComplete: number, startValue: number, endValue: number): number { | ||
if (percentComplete === 0) { | ||
return startValue; | ||
} | ||
if (percentComplete === 1) { | ||
return endValue; | ||
} | ||
return Math.pow(percentComplete, 2) * ((amount + 1) * percentComplete - amount) * (endValue - startValue); | ||
}]); | ||
} | ||
|
||
export function registerBackOut(name: string, amount: number) { | ||
registerEasing([name, function(percentComplete: number, startValue: number, endValue: number): number { | ||
if (percentComplete === 0) { | ||
return startValue; | ||
} | ||
if (percentComplete === 1) { | ||
return endValue; | ||
} | ||
return (Math.pow(--percentComplete, 2) * ((amount + 1) * percentComplete + amount) + 1) * (endValue - startValue); | ||
}]); | ||
} | ||
|
||
export function registerBackInOut(name: string, amount: number) { | ||
amount *= 1.525; | ||
registerEasing([name, function(percentComplete: number, startValue: number, endValue: number): number { | ||
if (percentComplete === 0) { | ||
return startValue; | ||
} | ||
if (percentComplete === 1) { | ||
return endValue; | ||
} | ||
return ((percentComplete *= 2) < 1 | ||
? (Math.pow(percentComplete, 2) * ((amount + 1) * percentComplete - amount)) | ||
: (Math.pow(percentComplete -= 2, 2) * ((amount + 1) * percentComplete + amount) + 2) | ||
) * 0.5 * (endValue - startValue); | ||
}]); | ||
} | ||
|
||
registerBackIn("easeInBack", 1.7); | ||
registerBackOut("easeOutBack", 1.7); | ||
registerBackInOut("easeInOutBack", 1.7); | ||
|
||
// TODO: Expose these as actions to register custom easings? | ||
}; |
This file contains 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
This file contains 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
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.