Skip to content

Instantly share code, notes, and snippets.

@jeroentbt
Created June 7, 2013 21:10
Show Gist options
  • Save jeroentbt/5732444 to your computer and use it in GitHub Desktop.
Save jeroentbt/5732444 to your computer and use it in GitHub Desktop.
speedInOut: Reverse easing function: speed in, slow down, speed out
// as found on http://stackoverflow.com/questions/7243065/help-with-custom-jquery-easing-function
// supporting math function (not included in the standard javascript Math object)
function sinh(aValue) {
var myTerm1 = Math.pow(Math.E, aValue);
var myTerm2 = Math.pow(Math.E, -aValue);
return (myTerm1-myTerm2)/2;
}
// adds the function to the javascript easing object
$.easing.speedInOut = function(x, t, b, c, d) {
return (sinh((x - 0.5) * 5) + sinh(-(x - 0.5)) + (sinh(2.5) + Math.sin(-2.5))) / (sinh(2.5) * 1.82);
};
// works fine like this as an easing function for eg skrollr
function(p) {
return (sinh((p - 0.5) * 5) + sinh(-(p - 0.5)) + (sinh(2.5) + Math.sin(-2.5))) / (sinh(2.5) * 1.82);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment