updated plugin GP Premium version 2.1.1

This commit is contained in:
2021-12-20 13:41:59 +00:00
committed by Gitium
parent 132b46b78f
commit d5dbb2bde7
86 changed files with 2903 additions and 455 deletions

View File

@ -1,16 +1,14 @@
jQuery( function( $ ) {
var throttle = function( callback, limit ) {
var wait = false;
var debounce = function( callback, wait ) {
var timeout;
return function() {
if ( ! wait ) {
callback.call();
wait = true;
clearTimeout( timeout );
setTimeout( function() {
wait = false;
}, limit );
}
timeout = setTimeout( function() {
timeout = undefined;
callback.call();
}, wait );
};
};
@ -66,7 +64,7 @@ jQuery( function( $ ) {
} );
} );
$( window ).on( 'scroll', throttle( function() {
$( window ).on( 'scroll', debounce( function() {
var panel = $( '.add-to-cart-panel' );
if ( panel.hasClass( 'item-added' ) ) {
@ -81,10 +79,12 @@ jQuery( function( $ ) {
if ( generateWooCommerce.stickyAddToCart ) {
var lastScroll = 0;
var scrollDownTimeout = 300;
$( window ).on( 'scroll', throttle( function() {
$( window ).on( 'scroll', debounce( function() {
var adminBar = $( '#wpadminbar' ),
stickyNav = $( '.navigation-stick' ),
stuckElement = $( '.stuckElement' ),
top = 0,
scrollTop = $( window ).scrollTop(),
panel = $( '.add-to-cart-panel' ),
@ -94,30 +94,36 @@ jQuery( function( $ ) {
buttonHeight = button.outerHeight(),
footerTop = $( '.site-footer' ).offset().top;
if ( adminBar.length ) {
top = adminBar.outerHeight();
}
if ( stickyNav.length ) {
if ( stickyNav.hasClass( 'auto-hide-sticky' ) ) {
if ( scrollTop < lastScroll && '0px' === stickyNav.css( 'top' ) ) {
top = top + stickyNav.outerHeight();
} else {
top = top;
}
lastScroll = scrollTop;
} else {
top = top + stickyNav.outerHeight();
}
if ( stuckElement.length === 0 ) {
scrollDownTimeout = 0;
}
if ( scrollTop > ( buttonTop + buttonHeight ) && panelPosition < footerTop ) {
panel.addClass( 'show-sticky-add-to-cart' ).css( {
'-webkit-transform': 'translateY(' + top + 'px)',
'-ms-transform': 'translateY(' + top + 'px)',
transform: 'translateY(' + top + 'px)',
} );
setTimeout( function() {
if ( adminBar.length ) {
top = adminBar.outerHeight();
}
if ( stickyNav.length ) {
if ( stickyNav.hasClass( 'auto-hide-sticky' ) ) {
if ( scrollTop < lastScroll && '0px' === stickyNav.css( 'top' ) ) {
top = top + stickyNav.outerHeight();
} else {
top = top;
}
lastScroll = scrollTop;
} else {
top = top + stickyNav.outerHeight();
}
}
panel.addClass( 'show-sticky-add-to-cart' ).css( {
'-webkit-transform': 'translateY(' + top + 'px)',
'-ms-transform': 'translateY(' + top + 'px)',
transform: 'translateY(' + top + 'px)',
} );
}, scrollDownTimeout );
} else {
panel.removeClass( 'show-sticky-add-to-cart' ).css( {
'-webkit-transform': '',
@ -125,7 +131,7 @@ jQuery( function( $ ) {
transform: '',
} );
}
}, 250 ) );
}, 50 ) );
$( '.go-to-variables' ).on( 'click', function( e ) {
e.preventDefault();