Currently, I am in the process of converting a piece of code from jQuery to plain JavaScript and CSS. The specific code snippet I am focusing on involves creating easing functions without relying on jQuery.
const customEasing = {
easeInExpo: function (x, t, b, c, d) {
return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
}
};
let nset = false;
document.querySelector('button#hmenu').addEventListener('click', function() {
if (!nset) {
document.querySelector('ul#nav').style.transitionDelay = '35ms';
document.querySelector('ul#nav').style.transitionDuration = '300ms';
document.querySelector('ul#nav').style.transitionTimingFunction = customEasing.easeInExpo;
document.querySelector('ul#nav').classList.add('active');
nset = true;
} else {
document.querySelector('ul#nav').style.transitionDuration = '550ms';
document.querySelector('ul#nav').classList.remove('active');
nset = false;
}
});
As I explore CSS transitions with easing functions, I'm curious about the available options. In my existing code, there are slideDown and slideUp easing functions that are utilized for a mobile menu navigation in a production environment.