Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scrolldir

Package Overview
Dependencies
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scrolldir - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

18

dist/scrolldir.auto.js
/**
scrolldir - Vertical scroll direction in CSS
@version v1.4.0
@version v1.5.0
@link https://github.com/dollarshaveclub/scrolldir.git

@@ -8,7 +8,6 @@ @author Patrick Fisher <patrick@pwfisher.com>

**/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
(function (factory) {
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
factory();
}(function () { 'use strict';

@@ -18,2 +17,4 @@ var attribute = 'data-scrolldir';

var thresholdPixels = 64; // Ignore moves smaller than this.
var el = document.documentElement;

@@ -26,4 +27,2 @@ var win = window;

var thresholdPixels = 64; // Ignore moves smaller than this.
var history = Array(historyLength);

@@ -90,3 +89,4 @@ var e; // last scroll event

if (opts.win) win = opts.win;
if (opts.dir) dir = opts.dir; // If opts.off, turn it off
if (opts.dir) dir = opts.dir;
if (opts.thresholdPixels) thresholdPixels = opts.thresholdPixels; // If opts.off, turn it off
// - set html[data-scrolldir="off"]

@@ -111,2 +111,2 @@ // - remove the event listener

})));
}));

@@ -1,1 +0,8 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e():"function"==typeof define&&define.amd?define(e):e()}(0,function(){"use strict";var a,f,t,d="data-scrolldir",u="down",s=document.documentElement,c=window,l=document.body,m=32,p=512,b=64,h=Array(m),v=0;function e(){var t=c.scrollY||c.pageYOffset,e=a.timeStamp,n="down"===u?Math.max:Math.min,i=l.scrollHeight-c.innerHeight;if(t=Math.max(0,t),t=Math.min(i,t),h.unshift({y:t,t:e}),h.pop(),t===n(f,t))return v=e,void(f=t);var o=e-p;if(v<o){f=t;for(var r=0;r<m&&(h[r]&&!(h[r].t<o));r+=1)f=n(f,h[r].y)}Math.abs(t-f)>b&&(f=t,v=e,u="down"===u?"up":"down",s.setAttribute(d,u))}function n(t){return a=t,c.requestAnimationFrame(e)}t&&(t.attribute&&(d=t.attribute),t.el&&(s=t.el),t.win&&(c=t.win),t.dir&&(u=t.dir),!0===t.off)?(s.setAttribute(d,"off"),c.removeEventListener("scroll",n)):(f=c.scrollY||c.pageYOffset,s.setAttribute(d,u),c.addEventListener("scroll",n))});
/**
scrolldir - Vertical scroll direction in CSS
@version v1.5.0
@link https://github.com/dollarshaveclub/scrolldir.git
@author Patrick Fisher <patrick@pwfisher.com>
@license MIT
**/
!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";var a,d,t,s="data-scrolldir",f="down",l=64,u=document.documentElement,c=window,m=document.body,h=32,v=512,w=Array(h),b=0;function e(){var t=c.scrollY||c.pageYOffset,e=a.timeStamp,n="down"===f?Math.max:Math.min,i=m.scrollHeight-c.innerHeight;if(t=Math.max(0,t),t=Math.min(i,t),w.unshift({y:t,t:e}),w.pop(),t===n(d,t))return b=e,void(d=t);var r=e-v;if(b<r){d=t;for(var o=0;o<h&&(w[o]&&!(w[o].t<r));o+=1)d=n(d,w[o].y)}Math.abs(t-d)>l&&(d=t,b=e,f="down"===f?"up":"down",u.setAttribute(s,f))}function n(t){return a=t,c.requestAnimationFrame(e)}t&&(t.attribute&&(s=t.attribute),t.el&&(u=t.el),t.win&&(c=t.win),t.dir&&(f=t.dir),t.thresholdPixels&&(l=t.thresholdPixels),!0===t.off)?(u.setAttribute(s,"off"),c.removeEventListener("scroll",n)):(d=c.scrollY||c.pageYOffset,u.setAttribute(s,f),c.addEventListener("scroll",n))});
/**
scrolldir - Vertical scroll direction in CSS
@version v1.4.0
@version v1.5.0
@link https://github.com/dollarshaveclub/scrolldir.git

@@ -11,2 +11,4 @@ @author Patrick Fisher <patrick@pwfisher.com>

var thresholdPixels = 64; // Ignore moves smaller than this.
var el = document.documentElement;

@@ -19,4 +21,2 @@ var win = window;

var thresholdPixels = 64; // Ignore moves smaller than this.
var history = Array(historyLength);

@@ -83,3 +83,4 @@ var e; // last scroll event

if (opts.win) win = opts.win;
if (opts.dir) dir = opts.dir; // If opts.off, turn it off
if (opts.dir) dir = opts.dir;
if (opts.thresholdPixels) thresholdPixels = opts.thresholdPixels; // If opts.off, turn it off
// - set html[data-scrolldir="off"]

@@ -86,0 +87,0 @@ // - remove the event listener

/**
scrolldir - Vertical scroll direction in CSS
@version v1.4.0
@version v1.5.0
@link https://github.com/dollarshaveclub/scrolldir.git

@@ -11,4 +11,4 @@ @author Patrick Fisher <patrick@pwfisher.com>

typeof define === 'function' && define.amd ? define(factory) :
(global.scrollDir = factory());
}(this, (function () { 'use strict';
(global = global || self, global.scrollDir = factory());
}(this, function () { 'use strict';

@@ -18,2 +18,4 @@ var attribute = 'data-scrolldir';

var thresholdPixels = 64; // Ignore moves smaller than this.
var el = document.documentElement;

@@ -26,4 +28,2 @@ var win = window;

var thresholdPixels = 64; // Ignore moves smaller than this.
var history = Array(historyLength);

@@ -90,3 +90,4 @@ var e; // last scroll event

if (opts.win) win = opts.win;
if (opts.dir) dir = opts.dir; // If opts.off, turn it off
if (opts.dir) dir = opts.dir;
if (opts.thresholdPixels) thresholdPixels = opts.thresholdPixels; // If opts.off, turn it off
// - set html[data-scrolldir="off"]

@@ -111,2 +112,2 @@ // - remove the event listener

})));
}));

@@ -1,1 +0,8 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.scrollDir=e()}(this,function(){"use strict";var f,u,a="data-scrolldir",d="down",s=document.documentElement,l=window,c=document.body,m=32,p=512,h=64,b=Array(m),v=0;function e(){var t=l.scrollY||l.pageYOffset,e=f.timeStamp,n="down"===d?Math.max:Math.min,r=c.scrollHeight-l.innerHeight;if(t=Math.max(0,t),t=Math.min(r,t),b.unshift({y:t,t:e}),b.pop(),t===n(u,t))return v=e,void(u=t);var i=e-p;if(v<i){u=t;for(var o=0;o<m&&(b[o]&&!(b[o].t<i));o+=1)u=n(u,b[o].y)}Math.abs(t-u)>h&&(u=t,v=e,d="down"===d?"up":"down",s.setAttribute(a,d))}function n(t){return f=t,l.requestAnimationFrame(e)}return function(t){return t&&(t.attribute&&(a=t.attribute),t.el&&(s=t.el),t.win&&(l=t.win),t.dir&&(d=t.dir),!0===t.off)?(s.setAttribute(a,"off"),l.removeEventListener("scroll",n)):(u=l.scrollY||l.pageYOffset,s.setAttribute(a,d),l.addEventListener("scroll",n))}});
/**
scrolldir - Vertical scroll direction in CSS
@version v1.5.0
@link https://github.com/dollarshaveclub/scrolldir.git
@author Patrick Fisher <patrick@pwfisher.com>
@license MIT
**/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).scrollDir=e()}(this,function(){"use strict";var s,d,f="data-scrolldir",u="down",a=64,l=document.documentElement,c=window,m=document.body,h=32,p=512,b=Array(h),v=0;function e(){var t=c.scrollY||c.pageYOffset,e=s.timeStamp,n="down"===u?Math.max:Math.min,r=m.scrollHeight-c.innerHeight;if(t=Math.max(0,t),t=Math.min(r,t),b.unshift({y:t,t:e}),b.pop(),t===n(d,t))return v=e,void(d=t);var i=e-p;if(v<i){d=t;for(var o=0;o<h&&(b[o]&&!(b[o].t<i));o+=1)d=n(d,b[o].y)}Math.abs(t-d)>a&&(d=t,v=e,u="down"===u?"up":"down",l.setAttribute(f,u))}function n(t){return s=t,c.requestAnimationFrame(e)}return function(t){return t&&(t.attribute&&(f=t.attribute),t.el&&(l=t.el),t.win&&(c=t.win),t.dir&&(u=t.dir),t.thresholdPixels&&(a=t.thresholdPixels),!0===t.off)?(l.setAttribute(f,"off"),c.removeEventListener("scroll",n)):(d=c.scrollY||c.pageYOffset,l.setAttribute(f,u),c.addEventListener("scroll",n))}});
{
"name": "scrolldir",
"version": "1.4.0",
"version": "1.5.0",
"description": "Vertical scroll direction in CSS",

@@ -39,11 +39,11 @@ "main": "dist/scrolldir.js",

"bower": "^1.7.9",
"es-check": "^2.0.0",
"es-check": "^5.0.0",
"eslint": "^5.0.1",
"node-qunit-phantomjs": "^2.0.0",
"qunit": "^2.6.2",
"rollup": "^0.65.0",
"rollup": "^0.68.0",
"rollup-plugin-babel": "^4.0.0-beta.0",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^5.0.2"
"rollup-plugin-uglify": "^6.0.0"
}
}

@@ -120,2 +120,8 @@ <figure align="center">

To change the `thresholdPixels`—the number of pixels to scroll before re-evaluating the direction:
```javascript
scrollDir({ thresholdPixels: someNumber }); // the default is 64 pixels
// example: scrollDir({ thresholdPixels: 10 })
```
## Example 🌴

@@ -122,0 +128,0 @@

let attribute = 'data-scrolldir'
let dir = 'down' // 'up' or 'down'
let thresholdPixels = 64 // Ignore moves smaller than this.
let el = document.documentElement

@@ -8,3 +9,2 @@ let win = window

const historyMaxAge = 512 // History data time-to-live (ms).
const thresholdPixels = 64 // Ignore moves smaller than this.
const history = Array(historyLength)

@@ -68,2 +68,3 @@ let e // last scroll event

if (opts.dir) dir = opts.dir
if (opts.thresholdPixels) thresholdPixels = opts.thresholdPixels
// If opts.off, turn it off

@@ -70,0 +71,0 @@ // - set html[data-scrolldir="off"]

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc