updated plugin GP Premium
version 2.1.1
This commit is contained in:
@ -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();
|
||||
|
Reference in New Issue
Block a user