Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. /**
  2. * 2019 DaLy @ dalys4s@yahoo.com
  3. *
  4. * NOTICE OF LICENSE
  5. *
  6. * This file is licenced under the Software License Agreement.
  7. * With the purchase or the installation of the software in your application
  8. * you accept the licence agreement
  9. *
  10. * @author DaLy @ <dalys4s@yahoo.com>
  11. * @copyright 2019 DaLy
  12. * @license Commercial license (You can not resell or redistribute this software.)
  13. *
  14. */
  15.  
  16. (function($) {
  17.  
  18. function hashHandler(){
  19. this.oldHash = window.location.hash;
  20. this.Check;
  21.  
  22. var that = this;
  23. var detect = function(){
  24. if(that.oldHash!=window.location.hash){
  25. var y = $(window).scrollTop();
  26. $(window).scrollTop(y+1);
  27. that.oldHash = window.location.hash;
  28. }
  29. };
  30. this.Check = setInterval(function(){ detect() }, 6);
  31. }
  32.  
  33. var hashDetection = new hashHandler();
  34. "use strict";
  35. $.fn.isInViewport = function() {
  36. var elementTop = $(this).offset().left;
  37. var elementBottom = elementTop + $(this).outerHeight();
  38. var viewportTop = $(window).scrollTop();
  39.  
  40. return elementBottom > viewportTop;
  41. };
  42. $(window).on('resize scroll', function() {
  43. $('.product-add-to-cart').each(function() {
  44. if ($(this).isInViewport()) {
  45. $("#sticky-atc").css({
  46. opacity: '0',
  47. visibility: "hidden",
  48. WebkitTransition: 'opacity 0.5s ease-in-out',
  49. MozTransition: 'opacity 0.5s ease-in-out',
  50. MsTransition: 'opacity 0.5s ease-in-out',
  51. OTransition: 'opacity 0.5s ease-in-out',
  52. transition: 'opacity 0.5s ease-in-out'
  53. });
  54. } else {
  55. $("#sticky-atc").css({
  56. opacity: 1,
  57. visibility: "visible",
  58. WebkitTransition: 'opacity 0.5s ease-in-out',
  59. MozTransition: 'opacity 0.5s ease-in-out',
  60. MsTransition: 'opacity 0.5s ease-in-out',
  61. OTransition: 'opacity 0.5s ease-in-out',
  62. transition: 'opacity 0.5s ease-in-out'
  63. });
  64. }
  65. });
  66. });
  67. $('#sticky-atc a.ajax_add_to_cart_button').click(function() {
  68. $(this).find('span').html($(this).find('span').html() + '...');
  69. });
  70. var sticky_cart_free = {
  71. addEl: '#sticky-add',
  72. init: function() {
  73. $(document).on('click', this.addEl, this.onAddClick);
  74. },
  75. onAddClick: function(e) {
  76. e.preventDefault();
  77. $('button.add-to-cart').trigger('click');
  78. }
  79. };
  80. sticky_cart_free.init();
  81. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement