assets/js
admin
1 month ago
modules
1 month ago
vendor
1 month ago
carousel.js
36.2 KB
1 month ago
carousel.min.js
19.3 KB
1 month ago
copy-to-clipboard.js
973 B
1 month ago
copy-to-clipboard.min.js
673 B
1 month ago
custom-addtocart-button.js
1.9 KB
1 month ago
custom-addtocart-button.min.js
1.2 KB
1 month ago
merchant.js
88 B
1 month ago
merchant.min.js
46 B
1 month ago
modal.js
1.5 KB
1 month ago
modal.min.js
1.1 KB
1 month ago
pagination.js
7.7 KB
1 month ago
pagination.min.js
4.8 KB
1 month ago
scroll-direction.js
1.2 KB
1 month ago
scroll-direction.min.js
792 B
1 month ago
scroll-to.js
1.6 KB
1 month ago
scroll-to.min.js
971 B
1 month ago
toggle-class.js
1.7 KB
1 month ago
toggle-class.min.js
998 B
1 month ago
scroll-direction.js in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.3.1, at assets/js/scroll-direction.js
| 1 | /** |
| 2 | * Merchant Scroll Direction. |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | 'use strict'; |
| 7 | |
| 8 | var merchant = merchant || {}; |
| 9 | merchant.scrollDirection = { |
| 10 | domReady: function domReady(fn) { |
| 11 | if (typeof fn !== 'function') { |
| 12 | return; |
| 13 | } |
| 14 | if (document.readyState === 'interactive' || document.readyState === 'complete') { |
| 15 | return fn(); |
| 16 | } |
| 17 | document.addEventListener('DOMContentLoaded', fn, false); |
| 18 | }, |
| 19 | init: function init() { |
| 20 | var elements = document.querySelectorAll('.merchant-sticky-add-to-cart-wrapper.hide-when-scroll'), |
| 21 | body = document.getElementsByTagName('body')[0]; |
| 22 | if ('null' === typeof elements) { |
| 23 | return; |
| 24 | } |
| 25 | var lastScrollTop = 0; |
| 26 | window.addEventListener('scroll', function () { |
| 27 | var scroll = window.pageYOffset || document.documentElement.scrollTop; |
| 28 | if (scroll > lastScrollTop) { |
| 29 | body.classList.remove('merchant-scrolling-up'); |
| 30 | body.classList.add('merchant-scrolling-down'); |
| 31 | } else { |
| 32 | body.classList.remove('merchant-scrolling-down'); |
| 33 | body.classList.add('merchant-scrolling-up'); |
| 34 | } |
| 35 | lastScrollTop = scroll <= 0 ? 0 : scroll; |
| 36 | }, false); |
| 37 | } |
| 38 | }; |
| 39 | |
| 40 | // Initialize. |
| 41 | merchant.scrollDirection.domReady(function () { |
| 42 | merchant.scrollDirection.init(); |
| 43 | }); |