| 1 |
(function($) { |
| 2 |
"use strict"; |
| 3 |
$(document).ready(function(){ |
| 4 |
var win = $(window); |
| 5 |
var totop = $('#easyel-top-to-bottom'); |
| 6 |
function checkScroll(currentScroll) { |
| 7 |
if (currentScroll > 150) { |
| 8 |
totop.fadeIn(); |
| 9 |
$('header').addClass('eel-scoll-to-top'); |
| 10 |
totop.addClass('eel-scroll-visible'); |
| 11 |
} else { |
| 12 |
totop.fadeOut(); |
| 13 |
$('header').removeClass('eel-scoll-to-top'); |
| 14 |
totop.removeClass('eel-scroll-visible'); |
| 15 |
} |
| 16 |
} |
| 17 |
if (window.lenis) { |
| 18 |
window.lenis.on('scroll', (e) => { |
| 19 |
checkScroll(e.scroll); |
| 20 |
}); |
| 21 |
} else { |
| 22 |
win.on('scroll', function() { |
| 23 |
checkScroll(win.scrollTop()); |
| 24 |
}); |
| 25 |
} |
| 26 |
totop.on('click', function(e) { |
| 27 |
e.preventDefault(); |
| 28 |
if (window.lenis) { |
| 29 |
window.lenis.scrollTo(0, { |
| 30 |
duration: 1.2, |
| 31 |
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)) |
| 32 |
}); |
| 33 |
} else { |
| 34 |
$("html, body").animate({ scrollTop: 0 }, 500); |
| 35 |
} |
| 36 |
}); |
| 37 |
}); |
| 38 |
})(jQuery); |