Easing

Par mowh, il y a 10 ans


Bonsoir,
Je suis sur la fin de mon portfolio et j'ai ajouté un "smooth scrolling" qui est le suivant :

$(function() { $('a[href*="#"]:not([href="#"])').bind('click',function(event){ var $anchor = $(this); $('body').stop().animate({ scrollTop: $($anchor.attr('href')).offset().top }, 1500); event.preventDefault(); }); });

Il marche parfaitement, mais je n'aime pas trop le easing "swing" de base. J'aimerais mettre un easing de type "easeInOutExpo". Voici comment j'ai fait :

$('body').stop().animate({ scrollTop: $($anchor.attr('href')).offset().top }, 1500, 'easeInOutExpo');

Et là, c'est comme si mon script ne marchait plus, plus de smooth scrolling, même pas en "swing".
J'ai essayé de mettre 'swing' et 'linear' à la place de 'easeInOutExpo' et ça marchait très bien...

Sauriez-vous d'où vient le problème ?

Merci d'avance !

2 réponses

larube, il y a 10 ans

Le 'easyInOutExpo' n'est pas disponible par défaut dans jQuery, tu as besoin d'inclure un plugin pour l'utiliser, par exemple http://api.jqueryui.com/easings/

mowh, il y a 10 ans

Super merci !