Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function () {
- let $scrollDoc,
- $basketBtn = $('#vmCartModule-sticky-wrapper'),
- $basketTop = $('#vmCartModule-sticky-wrapper').offset().top,
- rightContainer = $('.container')[0].getBoundingClientRect().right,
- widthDocument = document.documentElement.clientWidth,
- widthContainer = $('.container').outerWidth();
- let widthBtnBasket = $basketBtn.outerWidth();
- $(window).scroll(function () {
- $scrollDoc = $(window).scrollTop();
- if ($scrollDoc > $basketTop) {
- if (((widthDocument - widthContainer) / 2) > widthBtnBasket) {
- $basketBtn.css({
- 'position': 'fixed',
- 'left': (Math.ceil(rightContainer - 10)) + 'px',
- 'top': 0,
- });
- } else {
- $basketBtn.css({
- 'position': 'fixed',
- 'right': 0,
- 'top': 0,
- });
- }
- } else {
- $basketBtn.css('position', 'static');
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement