Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. (function($) {
  2. "use strict";
  3. $(function() {
  4. var container = $("#to_top_scrollup").css({
  5. 'opacity': 0
  6. });
  7. var data = to_top_options;
  8.  
  9. var mouse_over = false;
  10. var hideEventID = 0;
  11.  
  12. var fnHide = function() {
  13. clearTimeout(hideEventID);
  14. if (container.is(":visible")) {
  15. container.stop().fadeTo(200, 0, function() {
  16. container.hide();
  17. mouse_over = false;
  18. });
  19. }
  20. };
  21.  
  22. var fnHideEvent = function() {
  23. if (!mouse_over && data.enable_autohide == 1 ) {
  24. clearTimeout(hideEventID);
  25. hideEventID = setTimeout(function() {
  26. fnHide();
  27. }, data.autohide_time * 1000);
  28. }
  29. };
  30.  
  31. var scrollHandled = false;
  32. var fnScroll = function() {
  33. if (scrollHandled)
  34. return;
  35.  
  36. scrollHandled = true;
  37.  
  38. if ($(window).scrollTop() > data.scroll_offset) {
  39. container.stop().css("opacity", mouse_over ? 1 : parseFloat(data.icon_opacity/100)).show();
  40.  
  41. fnHideEvent();
  42.  
  43. } else {
  44. fnHide();
  45. }
  46.  
  47. scrollHandled = false;
  48. };
  49.  
  50. if ("undefined" != typeof to_top_options.enable_hide_small_device && "1" == to_top_options.enable_hide_small_device) {
  51. if ($(window).width() > to_top_options.small_device_max_width) {
  52. $(window).scroll(fnScroll);
  53. $(document).scroll(fnScroll);
  54. }
  55. }else{
  56. $(window).scroll(fnScroll);
  57. $(document).scroll(fnScroll);
  58. }
  59.  
  60. container
  61. .hover(function() {
  62. clearTimeout(hideEventID);
  63. mouse_over = true;
  64. $(this).css("opacity", 1);
  65. }, function() {
  66. $(this).css("opacity", parseFloat(data.icon_opacity/100));
  67. mouse_over = false;
  68. fnHideEvent();
  69. })
  70. .click(function() {
  71. $("html, body").animate({
  72. scrollTop: 0
  73. }, 400);
  74. return false;
  75. });
  76. });
  77. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement