PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.3.2
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.3.2
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
merchant / assets / js / scroll-direction.js

scroll-direction.js in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.3.2, at assets/js/scroll-direction.js

43 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 });