# merchant/2.3.2/assets/js/scroll-direction.js

Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together &amp; More for WooCommerce – Merchant, version 2.3.2. 43 lines.

- Page: https://pluginprobe.com/plugins/merchant/2.3.2/code/assets/js/scroll-direction.js
- Raw: https://pluginprobe.com/plugins/merchant/2.3.2/raw/assets/js/scroll-direction.js
- Modified: 2026-09-17T17:48:06+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/merchant/2.3.2/code/assets/js/scroll-direction.js#L10-L20`.

```javascript
/**
 * Merchant Scroll Direction.
 * 
 */

'use strict';

var merchant = merchant || {};
merchant.scrollDirection = {
  domReady: function domReady(fn) {
    if (typeof fn !== 'function') {
      return;
    }
    if (document.readyState === 'interactive' || document.readyState === 'complete') {
      return fn();
    }
    document.addEventListener('DOMContentLoaded', fn, false);
  },
  init: function init() {
    var elements = document.querySelectorAll('.merchant-sticky-add-to-cart-wrapper.hide-when-scroll'),
      body = document.getElementsByTagName('body')[0];
    if ('null' === typeof elements) {
      return;
    }
    var lastScrollTop = 0;
    window.addEventListener('scroll', function () {
      var scroll = window.pageYOffset || document.documentElement.scrollTop;
      if (scroll > lastScrollTop) {
        body.classList.remove('merchant-scrolling-up');
        body.classList.add('merchant-scrolling-down');
      } else {
        body.classList.remove('merchant-scrolling-down');
        body.classList.add('merchant-scrolling-up');
      }
      lastScrollTop = scroll <= 0 ? 0 : scroll;
    }, false);
  }
};

// Initialize.
merchant.scrollDirection.domReady(function () {
  merchant.scrollDirection.init();
});
```
