Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * 2019 DaLy @ dalys4s@yahoo.com
- *
- * NOTICE OF LICENSE
- *
- * This file is licenced under the Software License Agreement.
- * With the purchase or the installation of the software in your application
- * you accept the licence agreement
- *
- * @author DaLy @ <dalys4s@yahoo.com>
- * @copyright 2019 DaLy
- * @license Commercial license (You can not resell or redistribute this software.)
- *
- */
- (function($) {
- function hashHandler(){
- this.oldHash = window.location.hash;
- this.Check;
- var that = this;
- var detect = function(){
- if(that.oldHash!=window.location.hash){
- var y = $(window).scrollTop();
- $(window).scrollTop(y+1);
- that.oldHash = window.location.hash;
- }
- };
- this.Check = setInterval(function(){ detect() }, 6);
- }
- var hashDetection = new hashHandler();
- "use strict";
- $.fn.isInViewport = function() {
- var elementTop = $(this).offset().left;
- var elementBottom = elementTop + $(this).outerHeight();
- var viewportTop = $(window).scrollTop();
- return elementBottom > viewportTop;
- };
- $(window).on('resize scroll', function() {
- $('.product-add-to-cart').each(function() {
- if ($(this).isInViewport()) {
- $("#sticky-atc").css({
- opacity: '0',
- visibility: "hidden",
- WebkitTransition: 'opacity 0.5s ease-in-out',
- MozTransition: 'opacity 0.5s ease-in-out',
- MsTransition: 'opacity 0.5s ease-in-out',
- OTransition: 'opacity 0.5s ease-in-out',
- transition: 'opacity 0.5s ease-in-out'
- });
- } else {
- $("#sticky-atc").css({
- opacity: 1,
- visibility: "visible",
- WebkitTransition: 'opacity 0.5s ease-in-out',
- MozTransition: 'opacity 0.5s ease-in-out',
- MsTransition: 'opacity 0.5s ease-in-out',
- OTransition: 'opacity 0.5s ease-in-out',
- transition: 'opacity 0.5s ease-in-out'
- });
- }
- });
- });
- $('#sticky-atc a.ajax_add_to_cart_button').click(function() {
- $(this).find('span').html($(this).find('span').html() + '...');
- });
- var sticky_cart_free = {
- addEl: '#sticky-add',
- init: function() {
- $(document).on('click', this.addEl, this.onAddClick);
- },
- onAddClick: function(e) {
- e.preventDefault();
- $('button.add-to-cart').trigger('click');
- }
- };
- sticky_cart_free.init();
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement