ui-scroll-to.js 604 B

1234567891011121314151617181920
  1. (function ($) {
  2. "use strict";
  3. $.extend( jQuery.easing,{
  4. def: 'easeOutQuad',
  5. easeInOutExpo: function (x, t, b, c, d) {
  6. if (t==0) return b;
  7. if (t==d) return b+c;
  8. if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
  9. return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  10. }
  11. });
  12. $(document).on('click', '[ui-scroll-to]', function (e) {
  13. e.preventDefault();
  14. var target = $('#'+$(this).attr('ui-scroll-to'));
  15. $('html,body').animate({
  16. scrollTop: target.offset().top
  17. }, 600, 'easeInOutExpo');
  18. });
  19. })(jQuery);